Ejemplo n.º 1
0
 async def upcoming(self, ctx: commands.Context, date: str = None):
     """
     View upcoming availabilities for a week
     Can optionally specify a date to look up avails for said date
     Input date as: day/month/year
     #STAFF
     """
     if date is None:
         gen_week = [
             (ctx.guild.get_member(avail.userid).display_name + ":\n" + stamp_to_str(avail.date_start) + " - " +
              stamp_to_str(avail.date_end))
             for avail in self.availabilities
             if (dt.datetime.fromtimestamp(avail.date_start) < dt.datetime.utcnow() + dt.timedelta(weeks=1))
         ]
         await (BotEmbedPaginator(ctx, pages(numbered(gen_week), n=10,
                                             title='Availabilities for this week'))).run()
     else:
         gen_date = [
             (ctx.guild.get_member(avail.userid).display_name + ":\n" + stamp_to_str(avail.date_start) + " - " +
              stamp_to_str(avail.date_end))
             for avail in self.availabilities
             if (dt.datetime.fromtimestamp(avail.date_start).strftime("%Y-%m-%d") ==
                 parse(date, dayfirst=True).strftime("%Y-%m-%d"))
         ]
         await (BotEmbedPaginator(ctx, pages(numbered(
             gen_date),
             n=10, title=f'Availabilities for {parse(date).strftime("%Y-%b-%d")}'))).run()
Ejemplo n.º 2
0
 async def records(self, ctx: commands.Context,
                   member: Union[discord.Member, discord.User, int]):
     """
     Gets the moderation records for a user
     #STAFF
     """
     if not isinstance(member, int):
         member = member.id
     warns = await self.punishments.get_warn_records(member)
     bans = await self.punishments.get_ban_records(member)
     total = warns + bans
     if not total:
         await ctx.send(
             embed=discord.Embed(title=f"{member}'s warns",
                                 description="No records for this member"))
         return
     await BotEmbedPaginator(
         ctx,
         pages([
             f"**{w.typ}-{w.id}** - {w.reason[:100]}\n"
             f"- <@{w.staff}> - "
             f" {datetime.datetime.utcfromtimestamp(w.timestamp).strftime('%b %d %y %H:%M:%S')}"
             for w in sorted(total, key=lambda x: x.timestamp)
         ],
               8,
               f"{member}'s Records",
               fmt="%s")).run()
Ejemplo n.º 3
0
 async def listfilteredtoken(self, ctx: commands.Context):
     """
     Lists filtered tokens
     #STAFF
     """
     await BotEmbedPaginator(
         ctx,
         pages(numbered(config()["filters"]["token_blacklist"]), 10,
               "Filtered Tokens")).run()
Ejemplo n.º 4
0
 async def listfilteredwords(self, ctx: commands.Context):
     """
     Lists the filtered words
     #STAFF
     """
     await BotEmbedPaginator(
         ctx,
         pages(numbered(config()["filters"]["word_blacklist"]), 10,
               "Filtered Words")).run()
Ejemplo n.º 5
0
 async def availabilities(self, ctx: commands.Context, member: discord.Member):
     """
     Shows the availabilities of a user
     #STAFF
     """
     gen = [
         stamp_to_str(avail.date_start) + " - " + stamp_to_str(avail.date_end)
         for avail in self.availabilities if avail.userid == member.id
     ]
     await (BotEmbedPaginator(ctx, pages(numbered(
         gen),
         n=10, title=f'{member.display_name}\'s availabilities'))).run()
Ejemplo n.º 6
0
 async def listcustomreactions(self,
                               ctx: commands.Context,
                               trigger: str = None):
     """
     lists custom reactions, optionally by trigger
     #STAFF
     """
     cs_list: List[str] = self._search(trigger)
     if len(cs_list) == 0:
         if not trigger:
             return await ctx.send("No reactions")
         return await ctx.send(f"No reactions found for trigger `{trigger}`"
                               )
     await BotEmbedPaginator(ctx, pages(cs_list, 10, "Reactions",
                                        fmt="%s")).run()
Ejemplo n.º 7
0
 async def help(self, ctx: commands.Context, *, cmd_s: str = None):
     if cmd_s:
         cmd: commands.Command
         cmd = self.bot.get_command(cmd_s)
         if not cmd:
             for cmd in self.bot.commands:
                 if cmd_s in cmd.aliases:
                     break
             else:
                 return await ctx.send(embed=discord.Embed(
                     title="Command not found",
                     description=f"Command `{cmd_s}` is not a valid command"
                 ))
         if cmd.name in "ban,sban,softban,kick,skick".split(","):
             return await ctx.send(embed=discord.Embed(
                 title=cmd.name,
                 description=cogs.administration.moderation.MOD_HELP_STR))
         s, roles = parse_help_str(cmd.callback.__doc__)
         return await ctx.send(embed=discord.Embed(
             title=cmd.name,
             description=(roles[0].strip("# ") if roles else "") +
             f"\n{s.strip(NL)}\n" +  # noqa e131
             ("Aliases: " + ",".join(f"`{x}`" for x in cmd.aliases) +
              "\n" if cmd.aliases else "")))
     cmds: List[commands.Command] = sorted(self.bot.commands,
                                           key=lambda x: x.cog_name)
     lst = []
     for i in cmds:
         if i.callback.__doc__:
             s, roles = parse_help_str(i.callback.__doc__)
         else:
             continue
         if await self._is_allowed_for((s, roles), ctx):
             if s.strip("\n "):
                 s = s.strip("\n ").splitlines(keepends=False)[0]
             lst.append(f"`{i.name.strip()}`:  " +
                        (roles[0].strip("# ") if roles else "") + "\n" + s +
                        "\n" + ("Aliases: " + ",".join(f"`{x}`"
                                                       for x in i.aliases) +
                                "\n" if i.aliases else ""))
     embeds = pages(lst, 7, "Help", fmt="%s")
     if config()["roles"]["staff"] in [r.id for r in ctx.author.roles]:
         embeds.append(
             discord.Embed(
                 title="Help",
                 description=cogs.administration.moderation.MOD_HELP_STR))
     await BotEmbedPaginator(ctx, embeds).run()
Ejemplo n.º 8
0
 async def warnlog(self, ctx: commands.Context, member: discord.Member):
     """
     Gets the warnings for a user
     #STAFF
     """
     warns = await self.punishments.get_warn_records(member.id)
     if not warns:
         await ctx.send(
             embed=discord.Embed(title=f"{member}'s warns",
                                 description="No warnings for this member"))
         return
     await BotEmbedPaginator(
         ctx,
         pages([
             f"**W-{w.id}** - {w.reason[:100]}\n"
             f"- <@{w.staff}> - "
             f" {datetime.datetime.utcfromtimestamp(w.timestamp).strftime('%b %d %y %H:%M:%S')}"
             for w in warns
         ],
               8,
               f"{member}'s Warns",
               fmt="%s")).run()
Ejemplo n.º 9
0
 async def liststatus(self, ctx):
     """
     Lists kaede's statuses
     #OWNER
     """
     await BotEmbedPaginator(ctx, pages(numbered(config()["statuses"]), 10, "Statuses")).run()