Exemple #1
0
 async def daily(self, ctx):
     main.cur.execute('SELECT daily FROM stats WHERE user_id = %s',
                      (ctx.author.id, ))
     daily_check = str(main.cur.fetchone())
     utc = (int(time() % 86400) - 3600)
     if utc <= 0:
         utc += 86400
     next_time = main.time_convert(86400 - utc)
     if daily_check != '(True,)':
         main.stat_update(
             r'UPDATE stats SET daily = true WHERE user_id = %s',
             ctx.author.id)
         main.stat_update(
             r'UPDATE stats SET exp = exp + 100 WHERE user_id = %s',
             ctx.author.id)
         print(f'{ctx.author.id} claimed their dailies')
         await main.channel_embed(
             ctx, 'Claimed!',
             f'You have claimed your daily today and gained 100 exp!\nYou can claim your next daily in {next_time}'
         )
     else:
         await main.channel_embed(
             ctx, 'Oh no!',
             f'Unfortunately you have already claimed your dailies today\nCome back in {next_time} to claim your next daily!'
         )
Exemple #2
0
 async def on_message_edit(self, message_before, message_after):
     if message_after.author.discriminator != '0000':
         if message_after.content != '' and message_before.content != '':
             main.stat_update(
                 r'UPDATE stats SET edited = edited + 1 WHERE user_id = %s',
                 message_after.author.id)
             if message_before.author.id != main.ids(0):
                 if str(message_before.channel.id) not in exempt_channels:
                     if message_after.content != message_before.content:  # prevent logging embeds loading
                         if message_before.guild is None:
                             jump = 'DMs**'
                         else:
                             jump = f'{message_after.channel.mention}** [(jump)](https://discord.com/channels/{message_after.guild.id}/{message_after.channel.id}/{message_after.id})'
                         em_v = discord.Embed(
                             color=int(main.values(1), 16),
                             description=f'**Message edited in {jump}')
                         em_v.add_field(name='Befored Edit:',
                                        value=message_before.content,
                                        inline=False)
                         em_v.add_field(name='After Edit:',
                                        value=message_after.content,
                                        inline=False)
                         em_v.set_footer(
                             text=
                             f'{message_after.author.name} | ID: {message_after.author.id}',
                             icon_url=message_after.author.avatar_url)
                         channel = await self.bot.fetch_channel(main.ids(3))
                         await channel.send(embed=em_v)
                         print(
                             f'{message_after.author.id} edited a message, Before: \"{message_before.content}\" After: \"{message_after.content}\"'
                         )
Exemple #3
0
 async def flip(self, ctx):
     c = [SystemRandom().randrange(2)][0] + 1
     if c == 1:
         main.stat_update(
             r'UPDATE stats SET heads = heads + 1 WHERE user_id = %s',
             ctx.author.id)
         await main.channel_embed(ctx, '🗣 Heads! 🗣')
     else:
         main.stat_update(
             r'UPDATE stats SET tails = tails + 1 WHERE user_id = %s',
             ctx.author.id)
         await main.channel_embed(ctx, '🦅 Tails! 🦅')
Exemple #4
0
 async def on_message(self, message):
     if message.author.discriminator != '0000':
         main.stat_update(
             r'UPDATE stats SET messages = messages + 1 WHERE user_id = %s',
             message.author.id)
         if (message.guild is
                 None) and (message.author.id != main.ids(0)) and (str(
                     message.author.id) not in exempt_users):
             channel = self.bot.get_guild(main.ids(1)).get_channel(
                 main.ids(4))
             await main.log_embed(None, 'I have recieved a DM',
                                  message.content, channel, message.author)
             print(f'{message.author.id} dmed me \"{message.content}\"')
Exemple #5
0
async def regex_respond(self, message):
    b_guild = self.bot.get_guild(main.ids(1))
    main.cur.execute('SELECT * FROM response WHERE delete=false')
    match_regex = main.cur.fetchall()
    for x in match_regex:
        if re.search(x[0], message.content.lower()) is not None:
            main.stat_update(
                r'UPDATE stats SET triggered_responses = triggered_responses + 1 WHERE user_id = %s',
                message.author.id)
            if (b_guild.get_member(main.ids(0))
                    in message.mentions) or (message.content.startswith('!')):
                title = '' if x[1].lower() == 'none' else x[1]
                desc = '' if x[2].lower() == 'none' else x[2]
                await main.channel_embed(message.channel, title, desc)
                print(
                    f'{message.author.id} manually triggered response #{x[5]}')
                if message.guild is not None:
                    await message.delete()
            elif role_check(self, message.author.id, x[4]) is not True:
                title = '' if x[1].lower() == 'none' else x[1]
                desc = '' if x[2].lower() == 'none' else x[2]
                print(f'{message.author.id} triggered response #{x[5]}')
                em_v = discord.Embed(color=int(main.values(1), 16),
                                     title=title,
                                     description=desc)
                em_v.set_footer(
                    text=f'{message.author.name} | ID: {message.author.id}',
                    icon_url=message.author.avatar_url)
                auto_response = await message.channel.send(embed=em_v)
                await auto_response.add_reaction('🗑️')

                def check(dreaction, duser):
                    try:
                        return (auto_response.id == dreaction.message.id) and (
                            duser.id == message.author.id
                            or staffr_check(self, duser.id) is True)
                    except AttributeError:
                        pass

                try:
                    reaction, user = await self.bot.wait_for('reaction_add',
                                                             timeout=1800,
                                                             check=check)
                except asyncio.TimeoutError:
                    pass
                else:
                    if str(reaction) == '🗑️' and user.id != int(main.ids(0)):
                        try:
                            await auto_response.delete()
                        except AttributeError:
                            pass
Exemple #6
0
 async def on_message_delete(self, message):
     if message.author.discriminator != '0000':
         main.stat_update(
             r'UPDATE stats SET deleted = deleted + 1 WHERE user_id = %s',
             message.author.id)
         if (message.author.id != main.ids(0)) and (str(message.channel.id)
                                                    not in exempt_channels):
             channel = await self.bot.fetch_channel(main.ids(3))
             if message.guild is None:
                 del_channel = 'DMs'
             else:
                 del_channel = message.channel.mention
             await main.log_embed(
                 None, None,
                 f'**Message deleted in {del_channel}** \n{message.content}',
                 channel, message.author)
             print(
                 f'{message.author.id} message was deleted: \"{message.content}\"'
             )
Exemple #7
0
async def computer_rps(ctx, choice_num, choice, image):
    comp_choice = [SystemRandom().randrange(3)][0] + 1
    if comp_choice == 1:
        str_compchoice = 'Rock'
    elif comp_choice == 2:
        str_compchoice = 'Paper'
    else:
        str_compchoice = 'Scissors'
    if choice_num == comp_choice:
        title = 'We Tied :|'
        main.stat_update(
            r'UPDATE stats SET tied = tied + 1 WHERE user_id = %s',
            ctx.author.id)
        action = f'{choice} {tie} {str_compchoice}'
    elif choice_num + 1 < comp_choice or choice_num - 1 == comp_choice:
        title = 'You Won! :)'
        main.stat_update(r'UPDATE stats SET won = won + 1 WHERE user_id = %s',
                         ctx.author.id)
        if choice_num == 1:
            action = rock_scissors
        elif choice_num == 2:
            action = paper_rock
        else:
            action = scissors_paper
    else:
        if comp_choice == 1:
            action = rock_scissors
        elif comp_choice == 2:
            action = paper_rock
        else:
            action = scissors_paper
        title = 'You lost :('
        main.stat_update(
            r'UPDATE stats SET lost = lost + 1 WHERE user_id = %s',
            ctx.author.id)
    await main.channel_embed(ctx, title, action, image)
Exemple #8
0
 async def ls(self, ctx, choice=None):
     lizard_img = 'https://cdn.discordapp.com/attachments/819449117561585704/833170722050408499/lizard.png'
     spock_img = 'https://cdn.discordapp.com/attachments/819449117561585704/833170723908354058/spock.png'
     rock_lizard = 'Rock crushes Lizard'
     paper_spock = 'Paper disproves Spock'
     scissors_lizard = 'Scissors decapitates Lizard'
     lizard_paper = 'Lizard eats Paper'
     lizard_spock = 'Lizard poisons Spock'
     spock_rock = 'Spock vaporizes Rock'
     spock_scissors = 'Spock smashes Scissors'
     if (choice is None) or (choice.lower() not in [
             'rock', 'paper', 'scissors', 'lizard', 'spock'
     ]):
         return await Help.rpsls(self, ctx)
     if choice.lower() == 'rock':
         main.stat_update(
             r'UPDATE stats SET rock = rock + 1 WHERE user_id = %s',
             ctx.author.id)
         user_choice = 1
         image = rock_img
     elif choice.lower() == 'paper':
         main.stat_update(
             r'UPDATE stats SET paper = paper + 1 WHERE user_id = %s',
             ctx.author.id)
         user_choice = 2
         image = paper_img
     elif choice.lower() == 'scissors':
         main.stat_update(
             r'UPDATE stats SET scissors = scissors + 1 WHERE user_id = %s',
             ctx.author.id)
         user_choice = 3
         image = scissors_img
     elif choice.lower() == 'lizard':
         main.stat_update(
             r'UPDATE stats SET lizard = lizard + 1 WHERE user_id = %s',
             ctx.author.id)
         user_choice = 4
         image = lizard_img
     else:
         main.stat_update(
             r'UPDATE stats SET spock = spock + 1 WHERE user_id = %s',
             ctx.author.id)
         user_choice = 5
         image = spock_img
     comp_choice = [SystemRandom().randrange(5)][0] + 1
     if user_choice == 1 and comp_choice == 2:
         title = 'You lost :('
         action = paper_rock
     elif user_choice == 1 and comp_choice == 5:
         title = 'You lost :('
         action = spock_rock
     elif user_choice == 1 and comp_choice == 3:
         title = 'You Won! :)'
         action = rock_scissors
     elif user_choice == 1 and comp_choice == 4:
         title = 'You Won! :)'
         action = rock_lizard
     elif user_choice == 2 and comp_choice == 3:
         title = 'You lost :('
         action = scissors_paper
     elif user_choice == 2 and comp_choice == 4:
         title = 'You lost :('
         action = lizard_paper
     elif user_choice == 2 and comp_choice == 1:
         title = 'You Won! :)'
         action = paper_rock
     elif user_choice == 2 and comp_choice == 5:
         title = 'You Won! :)'
         action = paper_spock
     elif user_choice == 3 and comp_choice == 1:
         title = 'You lost :('
         action = rock_scissors
     elif user_choice == 3 and comp_choice == 5:
         title = 'You lost :('
         action = spock_scissors
     elif user_choice == 3 and comp_choice == 2:
         title = 'You Won! :)'
         action = scissors_paper
     elif user_choice == 3 and comp_choice == 4:
         title = 'You Won! :)'
         action = scissors_lizard
     elif user_choice == 4 and comp_choice == 1:
         title = 'You lost :('
         action = rock_lizard
     elif user_choice == 4 and comp_choice == 3:
         title = 'You lost :('
         action = scissors_lizard
     elif user_choice == 4 and comp_choice == 2:
         title = 'You Won! :)'
         action = lizard_paper
     elif user_choice == 4 and comp_choice == 5:
         title = 'You Won! :)'
         action = lizard_spock
     elif user_choice == 5 and comp_choice == 2:
         title = 'You lost :('
         action = paper_spock
     elif user_choice == 5 and comp_choice == 4:
         title = 'You lost :('
         action = lizard_spock
     elif user_choice == 5 and comp_choice == 1:
         title = 'You Won! :)'
         action = spock_rock
     elif user_choice == 5 and comp_choice == 3:
         title = 'You Won! :)'
         action = spock_scissors
     else:
         action = f'{choice} {tie} {choice}'
         title = 'We Tied :|'
         main.stat_update(
             r'UPDATE stats SET tied = tied + 1 WHERE user_id = %s',
             ctx.author.id)
     if title == 'You Won! :)':
         main.stat_update(
             r'UPDATE stats SET won = won + 1 WHERE user_id = %s',
             ctx.author.id)
     elif title == 'You lost :(':
         main.stat_update(
             r'UPDATE stats SET lost = lost + 1 WHERE user_id = %s',
             ctx.author.id)
     await main.channel_embed(ctx, title, action, image)
Exemple #9
0
 async def scissors(self, ctx):
     main.stat_update(
         r'UPDATE stats SET scissors = scissors + 1 WHERE user_id = %s',
         ctx.author.id)
     await computer_rps(ctx, 3, 'Scissors', scissors_img)
Exemple #10
0
 async def paper(self, ctx):
     main.stat_update(
         r'UPDATE stats SET paper = paper + 1 WHERE user_id = %s',
         ctx.author.id)
     await computer_rps(ctx, 2, 'Paper', paper_img)
Exemple #11
0
 async def rock(self, ctx):
     main.stat_update(
         r'UPDATE stats SET rock = rock + 1 WHERE user_id = %s',
         ctx.author.id)
     await computer_rps(ctx, 1, 'Rock', rock_img)