Esempio n. 1
0
 async def on_raw_bulk_message_delete(self, payload):
     channel = self.bot.get_channel(self.bot.config['guilds'][str(
         payload.guild_id)]['logchannel'])
     if channel is not None and self.valid_channel(
             payload.channel_id, guild_id=payload.guild_id):
         messages = payload.cached_messages
         if messages is not None:
             content = ''
             for message in messages:
                 content = content + '**{}#{}**\n{}\n'.format(
                     message.author.name, message.author.discriminator,
                     message.content)
             content = (content[-1500:] +
                        "\n...") if len(content) > 1500 else content
             embed = generic_embed(
                 description='**{} Messages Deleted in <#{}>**\n'.format(
                     str(len(messages)), payload.channel_id) + content,
                 color=COLORS['RED'],
                 author=self.bot.author)
         else:
             idList = ''
             for id in payload.message_ids:
                 idList = idList + str(id) + '\n'
             embed = generic_embed(
                 description='**Message Deleted in <#{}>**\n{}'.format(
                     payload.channel_id, idList),
                 color=COLORS['RED'],
                 author=self.bot.author)
         await channel.send(content=None, embed=embed)
Esempio n. 2
0
 async def blacklist(self, ctx, action, word: typing.Optional[str] = None):
     if Utils.checkPerms(ctx, ctx.author):
         if action == 'add':
             if word not in self.bot.config['guilds'][str(
                     ctx.guild.id)]['blacklist']['words']:
                 self.bot.config['guilds'][str(
                     ctx.guild.id)]['blacklist']['words'].append(word)
             else:
                 ctx.send(
                     content="{} is already on the blacklist.".format(word))
         if action in ['remove', 'delete']:
             if word in self.bot.config['guilds'][str(
                     ctx.guild.id)]['blacklist']['words']:
                 self.bot.config['guilds'][str(
                     ctx.guild.id)]['blacklist']['words'].remove(word)
             else:
                 ctx.send(
                     content="{} is not on the blacklist.".format(word))
         if action == 'print':
             content = ''
             for word in self.bot.config['guilds'][str(
                     ctx.guild.id)]['blacklist']['words']:
                 content = content + word + '\n'
             await ctx.send(content=None,
                            embed=generic_embed(title="Blacklist",
                                                description=content,
                                                author=self.bot.user))
         self.bot.save()
     else:
         await ctx.send(
             content='You do not have permissions for this command')
Esempio n. 3
0
 async def on_member_unban(self, guild, member):
     channel = self.bot.get_channel(self.bot.config['guilds'][str(
         guild.id)]['logchannel'])
     if channel is not None:
         embed = generic_embed(
             title='User `{}` unbanned.'.format(member.mention),
             color=COLORS['GREEN'],
             footer='User ID: {} | {}'.format(member.id,
                                              str(datetime.datetime.now())))
         await channel.send(content=None, embed=embed)
Esempio n. 4
0
 async def on_member_ban(self, guild, member):
     channel = self.bot.get_channel(self.bot.config['guilds'][str(
         guild.id)]['logchannel'])
     if channel is not None:
         reason = str((await guild.fetch_ban(member)).reason).split(':')
         try:
             embed = generic_embed(
                 title='User `{}` banned.'.format(member.mention),
                 description='**Name:** {}\n**Reason:** `{}`'.format(
                     reason[0], reason[1]),
                 color=COLORS['ORANGE'],
                 footer='User ID: {} | {}'.format(
                     member.id, str(datetime.datetime.now())))
         except:
             embed = generic_embed(
                 title='User `{}` banned.'.format(member.mention),
                 description='**Name:** {}'.format(member.name),
                 color=COLORS['ORANGE'],
                 footer='User ID: {} | {}'.format(
                     member.id, str(datetime.datetime.now())))
         await channel.send(content=None, embed=embed)
Esempio n. 5
0
 async def on_raw_message_delete(self, payload):
     channel = self.bot.get_channel(self.bot.config['guilds'][str(
         payload.guild_id)]['logchannel'])
     if channel is not None and self.valid_channel(
             payload.channel_id, guild_id=payload.guild_id):
         message = payload.cached_message
         if message is not None:
             embed = generic_embed(
                 description='**Message Deleted in {}**'.format(
                     message.channel.mention) +
                 '\n{}'.format(message.content),
                 color=COLORS['RED'],
                 author=message.author,
                 footer='ID: {} | Msg ID: {} • {}'.format(
                     message.author.id, message.id, message.edited_at))
         else:
             embed = generic_embed(
                 description='**Message Deleted in <#{}>**\n{}'.format(
                     payload.channel_id, payload.message_id),
                 color=COLORS['RED'],
                 author=self.bot.author)
         await channel.send(content=None, embed=embed)
Esempio n. 6
0
 async def on_member_remove(self, member):
     channel = self.bot.get_channel(self.bot.config['guilds'][str(
         member.guild.id)]['logchannel'])
     if channel is not None:
         embed = generic_embed(
             description='{} **{}#{}**'.format(member.mention,
                                               member.display_name,
                                               member.discriminator),
             color=COLORS['ORANGE'],
             footer='Left At: {} | ID: {}'.format(member.joined_at,
                                                  member.id))
         embed.set_author(name='Member Left', icon_url=member.avatar_url)
         await channel.send(content=None, embed=embed)
Esempio n. 7
0
 async def roles_print(self, ctx, level: typing.Optional[str] = None):
     if Utils.checkPerms(ctx, ctx.author):
         Utils.checkPerms(ctx, ctx.author)
         if level is None:
             try:
                 content = ''
                 for level, roles in self.bot.config['guilds'][str(
                         ctx.guild.id)]['roles'].items():
                     content = content + '**{}**\n'.format(level)
                     for role in roles:
                         content = content + '{}\n'.format(
                             ctx.guild.get_role(int(role)).mention)
                 await ctx.send(content=None,
                                embed=generic_embed(title='Internal Roles',
                                                    description=content,
                                                    author=self.bot.user))
             except:
                 await ctx.send(content='No roles found')
         else:
             try:
                 level = level.lower()
                 content = ''
                 for role in self.bot.config['guilds'][str(
                         ctx.guild.id)]['roles'][level]:
                     content = content + '{}\n'.format(
                         ctx.guild.get_role(int(role)).mention)
                 await ctx.send(content=None,
                                embed=generic_embed(
                                    title='{}'.format(level),
                                    description=content,
                                    author=self.bot.user))
             except:
                 await ctx.send(content='{} not found.'.format(level))
     else:
         await ctx.send(
             content='You do not have permissions for this command')
Esempio n. 8
0
 async def on_member_update(self, before, after):
     channel = self.bot.get_channel(self.bot.config['guilds'][str(
         before.guild.id)]['logchannel'])
     if channel is not None and before.nick != after.nick:
         embed = generic_embed(description='{} **{}#{}**'.format(
             after.mention, after.name, after.discriminator),
                               color=COLORS['YELLOW'],
                               footer='User ID: {}'.format(before.id),
                               fields={
                                   'Before': before.nick,
                                   'After': after.nick
                               })
         embed.set_author(name='Member Name Changed'.format(
             before.name, before.discriminator),
                          icon_url=after.avatar_url)
         await channel.send(content=None, embed=embed)
Esempio n. 9
0
 async def print(self, ctx, level):
     if Utils.checkPerms(ctx, ctx.author):
         level = level.lower()
         if level in self.bot.config['guilds'][str(
                 ctx.guild.id)]['permissions']:
             content = ''
             for permission in self.bot.config['guilds'][str(
                     ctx.guild.id)]['permissions'][level]:
                 content = content + permission + "\n"
             await ctx.send(content=None,
                            embed=generic_embed(title=level.upper(),
                                                description=content,
                                                author=self.bot.user))
         else:
             await ctx.send(
                 content='**{}** is not registered in permissions.'.format(
                     level))
     else:
         await ctx.send(
             content='You do not have permissions for this command')
Esempio n. 10
0
 async def on_message_edit(self, before, after):
     try:
         channel = self.bot.get_channel(self.bot.config['guilds'][str(
             after.guild.id)]['logchannel'])
         if channel is not None and before.content != after.content and self.valid_channel(
                 before.channel.id, guild_id=before.guild.id):
             embed = generic_embed(
                 description='**Message Edited in {}**'.format(
                     before.channel.mention),
                 color=COLORS['AQUA'],
                 footer='User ID: {}'.format(before.id),
                 fields={
                     'Before': before.content,
                     'After': after.content
                 },
                 author=before.author)
             await channel.send(content=None, embed=embed)
     except:
         print(
             "Message Edit Error: {} is no longer in this discord.".format(
                 before.name))