async def on_reaction_add(self, reaction, user): emoji = reaction.emoji db = sqlite3.connect('main.sqlite') cursor = db.cursor() cursor.execute(f'SELECT channel_id FROM application WHERE 1') channel = cursor.fetchone() channel_id = self.client.get_channel(int(channel[0])) cursor.execute('SELECT app_category FROM staffApp WHERE 1') categoryId = cursor.fetchone() category = int(categoryId[0]) print(category) categoryTest = discord.CategoryChannel(category.id) #category = cursor.fetchone() #category_id = category[0] guild = user.guild categories = 1000 if user.bot: return if emoji == "\U0001F4E9": await channel_id.send("You clicked the Staff Application") print(categories) await guild.create_text_channel("Staff", category=category) elif emoji == "\U000023EF": await channel_id.send("You clicked the Youtube Application") else: return
async def test_server_info_command(self, time_since_patch): time_since_patch.return_value = '2 days ago' self.ctx.guild = helpers.MockGuild( features=('lemons', 'apples'), region="The Moon", roles=[self.moderator_role], channels=[ discord.TextChannel( state={}, guild=self.ctx.guild, data={'id': 42, 'name': 'lemons-offering', 'position': 22, 'type': 'text'} ), discord.CategoryChannel( state={}, guild=self.ctx.guild, data={'id': 5125, 'name': 'the-lemon-collection', 'position': 22, 'type': 'category'} ), discord.VoiceChannel( state={}, guild=self.ctx.guild, data={'id': 15290, 'name': 'listen-to-lemon', 'position': 22, 'type': 'voice'} ) ], members=[ *(helpers.MockMember(status=discord.Status.online) for _ in range(2)), *(helpers.MockMember(status=discord.Status.idle) for _ in range(1)), *(helpers.MockMember(status=discord.Status.dnd) for _ in range(4)), *(helpers.MockMember(status=discord.Status.offline) for _ in range(3)), ], member_count=1_234, icon_url='a-lemon.jpg', ) self.assertIsNone(await self.cog.server_info(self.cog, self.ctx)) time_since_patch.assert_called_once_with(self.ctx.guild.created_at, precision='days') _, kwargs = self.ctx.send.call_args embed = kwargs.pop('embed') self.assertEqual(embed.colour, discord.Colour.blurple()) self.assertEqual( embed.description, textwrap.dedent( f""" **Server information** Created: {time_since_patch.return_value} Voice region: {self.ctx.guild.region} Features: {', '.join(self.ctx.guild.features)} **Channel counts** Category channels: 1 Text channels: 1 Voice channels: 1 Staff channels: 0 **Member counts** Members: {self.ctx.guild.member_count:,} Staff members: 0 Roles: {len(self.ctx.guild.roles)} **Member statuses** {constants.Emojis.status_online} 2 {constants.Emojis.status_idle} 1 {constants.Emojis.status_dnd} 4 {constants.Emojis.status_offline} 3 """ ) ) self.assertEqual(embed.thumbnail.url, 'a-lemon.jpg')
} super().__init__(**collections.ChainMap(kwargs, default_kwargs)) # Create CategoryChannel instance to get a realistic MagicMock of `discord.CategoryChannel` category_channel_data = { 'id': 1, 'type': discord.ChannelType.category, 'name': 'category', 'position': 1, } state = unittest.mock.MagicMock() guild = unittest.mock.MagicMock() category_channel_instance = discord.CategoryChannel(state=state, guild=guild, data=category_channel_data) class MockCategoryChannel(CustomMockMixin, unittest.mock.Mock, HashableMixin): def __init__(self, **kwargs) -> None: default_kwargs = {'id': next(self.discord_id)} super().__init__(**collections.ChainMap(default_kwargs, kwargs)) # Create a Message instance to get a realistic MagicMock of `discord.Message` message_data = { 'id': 1, 'webhook_id': 431341013479718912, 'attachments': [], 'embeds': [],