Beispiel #1
0
    async def on_guild_join(self, guild: Guild):
        text = f"✅{guild.me.mention} was added by `{guild.name}({guild.id})`. Member count: `{guild.member_count}`✅"
        await self.send_update(text, self.bot_join_leave, guild)

        g = get_guild(guild)
        GuildStats(g_joined=g, count=1,
                   total_count=len(self.bot.guilds)).save()
Beispiel #2
0
 async def on_member_ban(self, d_g: Guild, member: Member):
     try:
         pass
     except Exception as e:
         f = models.Error(g=get_guild(d_g),
                          cmd_string="on member ban error",
                          error_type=f'{type(e)}',
                          error=f'{e}',
                          traceback=traceback.format_exc())
         f.save()
         await self.notify_error_bot_owner(f, d_g)
 async def dummy_task(self):
     for d_g in self.bot.guilds:
         d_g: Guild
         try:
             pass
             #Some function can be called here for every guild
         except Exception as e:
             d_g = self.bot.guilds[0]
             f = models.Error(g=get_guild(d_g),
                              cmd_string=f"Dummy task error {d_g.name}",
                              error_type=f'{type(e)}',
                              error=f'{e}',
                              traceback=traceback.format_exc())
             f.save()
             await self.notify_error_bot_owner(f, d_g)
Beispiel #4
0
    async def on_guild_remove(self, guild: Guild):
        text = f"❌{guild.me.mention} was removed from `{guild.name}({guild.id})`. Member count: `{guild.member_count}`❌"
        await self.send_update(text, self.bot_join_leave, guild)
        g = get_guild(guild)

        try:
            related_guild_stat = GuildStats.objects.filter(
                g_joined=g).order_by('timestamp').last()
        except:
            related_guild_stat = None

        GuildStats(g_left=g,
                   related_object=related_guild_stat,
                   count=-1,
                   total_count=len(self.bot.guilds)).save()
Beispiel #5
0
    async def on_error(event, *args, **kwargs):
        try:
            g_obj = args[0].guild
        except AttributeError:
            g_obj = bot.get_guild(args[0].guild_id)
        try:
            g = get_guild(g_obj)
        except AttributeError:
            g = None
        sys_info = sys.exc_info()
        e = Error(g=g,
                  cmd_string=event,
                  error_type=f'{sys_info[0]}',
                  error=f'{sys_info[1]}',
                  traceback=traceback.format_exc())
        e.save()
        bot_owner: 'DBotOwner' = bot.get_cog('DBotOwner')

        await bot_owner.send_error_notification(e, g_obj)