diff --git a/AsmOrg-bot/bot.py b/AsmOrg-bot/bot.py new file mode 100644 index 0000000000000000000000000000000000000000..bfcb11e40dc3c755d89fb09ad9c5288780f51e97 --- /dev/null +++ b/AsmOrg-bot/bot.py @@ -0,0 +1,38 @@ +# Author: samip5 + +import discord +from discord.ext import commands +import datetime + + +def get_prefix(bot, message): + prefixes = ['!!'] + return commands.when_mentioned_or(*prefixes)(bot, message) + + +bot = commands.Bot(command_prefix=get_prefix) + + +@bot.event +async def on_ready(): + bot.uptime = datetime.datetime.utcnow() + print('Logged in as:\n{0} (ID: {0.id})'.format(bot.user)) + bot.accept_invite('https://discord.gg/mPUDfwa') + print(f'Servers count: {len(bot.servers)}') + + +@bot.event +async def on_message(message): + if message.channel.is_private and message.content.startswith('http') or message.channel.is_private and message.content.startswith('https'): + try: + invite = await bot.get_invite(message.content) + await bot.accept_invite(invite) + await bot.send_message(message.channel, 'Joined the server.') + except: + # if an error occurs at this point then ignore it and move on. + pass + finally: + return + await bot.process_commands(message) + +bot.run() \ No newline at end of file