import discord import discord.ext.commands as commands class serverTest(commands.Cog): def __init__(self, bot): self.bot = bot self.image_servers = { 'image-server-0': 987258103508664340, 'image-server-1': 987255984567242772, 'image-server-2': 987256008491544657, 'image-server-3': 987256063302713344, 'image-server-4': 987256085108916225, 'image-server-5': 987256103681294376, 'image-server-6': 987256159155146803, 'image-server-7': 987256715374395422, 'image-server-8': 987256757170618398, 'image-server-9': 987256802087415858, } @commands.command(name='getid') async def text_channel_get_id(self, ctx): """ Prints out the """ file_path = r'C:\Users\haose\OneDrive\Desktop\jerry.png' tc_ptr = 0 # retrieve TextChannel objects for tc in ctx.guild.text_channels: if 'image-server' in tc.name: print(f"'{tc.name}': {tc.id},") # spam file uploads to TextChannels. # for _ in range(90): # await tc_testing[tc_ptr].send(file=discord.File(file_path)) # tc_ptr = (tc_ptr + 1) % len(tc_testing) @commands.command(name='testspam') async def text_channge_spam_test(self, ctx): """ Tests the behavior of multiple text channels in the same server getting spammed with file uploads. """ file_path = r'C:\Users\haose\OneDrive\Desktop\jerry.png' tc_ptr = 0 tc_ids = self.image_servers.values() tcs = list() for tc_id in tc_ids: tcs.append(self.bot.get_channel(tc_id)) for _ in range(100): await tcs[tc_ptr].send(file=discord.File(file_path)) tc_ptr = (tc_ptr + 1) % len(tcs) async def setup(bot): await bot.add_cog(serverTest(bot))