import os import random from discord.ext import commands TOKEN = os.getenv('token') bot = commands.Bot(command_prefix='!') @bot.event async def on_ready(): print(f'{bot.user.name} has connected to Discord!') # @bot.event # async def on_member_join(member): # await member.create_dm() # await member.dm_channel.send( # f'Hi {member.name}, welcome to my ths server!' # ) @bot.command(name='corona') async def corona(ctx): import corona result = corona.parse_message(ctx.message.content) await ctx.send(embed=result) @bot.command(name='stock') async def stock(ctx): import stock result = stock.parse_message(ctx.message.content) await ctx.send(embed=result) @bot.command(name='8ball') async def eight_ball(ctx): import eight_ball result = eight_ball.check_8ball(ctx.message.content) await ctx.send(result) @bot.command(name='purge') async def purge(ctx): def is_me(m): return m.author == ctx.message.author num = 20 if len(ctx.message.content.split()) > 1: try: num = int(ctx.message.content.split()[1]) + 1 except ValueError: await ctx.send( ctx.message.channel, "You need to give me a number, you entered {}".format( ctx.message.content.split()[1] ) ) return await ctx.message.channel.purge(limit=num, check=is_me) @bot.command(name='cleanup') async def cleanup(ctx): def is_discord_bot(m): return m.author == bot.user num = 20 if len(ctx.message.content.split()) > 1: try: num = int(ctx.message.content.split()[1]) + 1 except ValueError: await ctx.send( ctx.message.channel, "You need to give me a number, you entered {}".format( ctx.message.content.split()[1] ) ) return await ctx.message.channel.purge(limit=num, check=is_discord_bot) bot.run(TOKEN)