Esempio n. 1
0
 async def on_raw_reaction_remove(self, payload):
     if (nextcord.utils.utcnow() -
             nextcord.Object(payload.message_id).created_at).days >= 7:
         return
     message = await self.bot.get_channel(payload.channel_id
                                          ).fetch_message(payload.message_id
                                                          )
     config = tt.config.find_one({'_id': message.guild.id}, {
         'starboard': 1,
         'starboardcount': 1,
         'starboardemoji': 1
     })
     if not config:
         return
     if self.starboard_emoji(config, payload.emoji):
         reaction = get(message.reactions,
                        emoji=payload.emoji.name if
                        payload.emoji.is_unicode_emoji() else payload.emoji)
         stored = self.db.find_one({'_id': message.id}, {'_id': 0})
         if stored != None and reaction != None:
             if stored['channel'] != config['starboard']:
                 self.db.delete_one({'_id': message.id})
                 return
             try:
                 boardmsg = await self.bot.get_channel(
                     config['starboard']).fetch_message(stored['board'])
                 content = await self.starboard_content(
                     message, reaction.count)
                 if content[0] != boardmsg.content and content[
                         1] != boardmsg.embeds[0]:
                     await boardmsg.edit(content=content[0],
                                         embed=content[1])
             except:
                 self.db.delete_one({'_id': message.id})
Esempio n. 2
0
    async def show_help(self, ctx, cmd: Optional[str]):
        if cmd is None:
            menu = ButtonMenuPages(
                source=HelpMenu(ctx, list(self.bot.commands),
                                list(self.bot.commands)),
                clear_reactions_after=True,
                timeout=60.0,
                style=nextcord.ButtonStyle.primary,
            )
            await menu.start(ctx)

        else:
            if command := get(self.bot.commands, name=cmd):
                await self.cmd_help(ctx, command)

            else:
Esempio n. 3
0
    async def history(self, ctx, member: Member):
        history = list(
            ModAction.select()
            .limit(50)
            .order_by(ModAction.datetime.desc())
            .where(ModAction.user_id == member.id)
        )
        message = f"{member.mention} has no mod action history."
        title = f"Mod History for {member}"
        if (
            ctx.invoked_with.casefold() == "whois"
            or not ctx.author.guild_permissions.manage_messages
        ):
            message = f"Here are some details about {member.mention}"
            title = f"Who is {member}"
        elif len(history):
            action_items = []
            for action in history:
                details = pickle.loads(action.details.encode())
                msg = details.get("message", "*No message*")
                link_url = details.get("link", None)
                link = f"\n[Jump To Action]({link_url})" if link_url else ""
                action_items.append(
                    f"**{action.action_type:6} {action.datetime:%d/%m/%Y}**\n{msg}{link}"
                )
            message = "\n".join(action_items)

        how_long_ago = pytz.utc.localize(datetime.utcnow()) - member.joined_at
        how_long_ago_msg = "Just now"
        if how_long_ago > timedelta(days=1):
            how_long_ago_msg = f"{how_long_ago // timedelta(days=1)} days ago"
        elif how_long_ago > timedelta(hours=1):
            how_long_ago_msg = f"{how_long_ago // timedelta(hours=1)} hours ago"
        elif how_long_ago > timedelta(minutes=5):
            how_long_ago_msg = f"{how_long_ago // timedelta(minutes=1)} minutes ago"

        await ctx.send(
            embed=Embed(
                title=title,
                description=message,
                color=0xFFE873,
            )
            .add_field(name="Joined", value=how_long_ago_msg)
            .add_field(name="User ID", value=str(member.id))
            .add_field(
                name="Are They Sus?",
                value="🚨 Yes 🚨"
                if utils.get(ctx.guild.roles, name="🚨sus🚨") in member.roles
                else "No, they cool 😎",
            )
        )
Esempio n. 4
0
    async def mute(self, ctx, member: Member, duration, *, reason: str):
        if not (
            set(ctx.author.roles)
            & {self.get_role("jedi council"), self.get_role("mods")}
        ):
            return

        muted_role = utils.get(ctx.guild.roles, name="Muted")
        if muted_role in member.roles:
            await ctx.send(f"*{member.mention} is already muted*")
            return

        await member.add_roles(muted_role, reason="Mod Mute")

        minutes = self.parse_duration(duration)
        embed = self.build_mod_action_embed(
            ctx, member, reason, f"Muted for {self.format_duration(minutes)}"
        )
        message = await ctx.send(embed=embed)

        successfully_dmd = await self.send_dm(
            member, embed, ctx.message, "You've been muted on the Beginner.py server.\n"
        )
        if not successfully_dmd:
            reason += "\n*Unable to DM user*"

        await self.log_action(
            "MUTE",
            member,
            ctx.author,
            reason,
            message,
            Duration=self.format_duration(minutes),
        )

        schedule(
            "unmute-member", timedelta(minutes=minutes), self.unmute_member, member.id
        )

        self.save_action(
            "MUTE",
            member,
            ctx.author,
            message=reason,
            reference=message.id,
            link=message.jump_url,
        )
Esempio n. 5
0
 async def createrole(self, ctx, colour, *role):
     if get(ctx.guild.roles, name=f"{role}"):
         await ctx.send("Role already exists")
         return
     regex = "^([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"
     p = re.compile(regex)
     if re.search(p, str(colour)):
         guild = ctx.guild
         colour_of_role = '0x' + str(colour)
         print(colour_of_role)
         await guild.create_role(name=role,
                                 color=nextcord.Colour(int(f'{colour}',
                                                           16)))
         print("role Created")
         await ctx.send(f"{role} created with colour code {colour_of_role}")
     else:
         await ctx.send("Enter a valid hex colour code")
Esempio n. 6
0
 async def on_raw_reaction_add(self, payload):
     if payload.member.bot or (nextcord.utils.utcnow() - nextcord.Object(
             payload.message_id).created_at).days >= 7:
         return
     message = await self.bot.get_channel(payload.channel_id
                                          ).fetch_message(payload.message_id
                                                          )
     config = tt.config.find_one({'_id': message.guild.id}, {
         'starboard': 1,
         'starboardcount': 1,
         'starboardemoji': 1
     })
     if not config:
         return
     if 'starboard' in config and self.starboard_emoji(
             config, payload.emoji):
         reaction = get(message.reactions,
                        emoji=payload.emoji.name if
                        payload.emoji.is_unicode_emoji() else payload.emoji)
         if reaction.count >= int(config['starboardcount']
                                  ) if 'starboardcount' in config else 5:
             content = await self.starboard_content(message, reaction.count)
             stored = self.db.find_one({'_id': message.id}, {'_id': 0})
             if stored != None:
                 if stored['channel'] != config['starboard']:
                     self.db.delete_one({'_id': message.id})
                     return
                 boardmsg = await self.bot.get_channel(
                     config['starboard']).fetch_message(stored['board'])
                 if content[0] != boardmsg.content or content[
                         1] != boardmsg.embeds[0]:
                     await boardmsg.edit(content=content[0],
                                         embed=content[1])
             else:
                 boardmsg = await self.bot.get_channel(
                     config['starboard']).send(content=content[0],
                                               embed=content[1])
                 self.db.update_one({'_id': message.id}, {
                     "$set": {
                         'board': boardmsg.id,
                         'channel': config['starboard'],
                         'date': message.created_at
                     }
                 },
                                    upsert=True)