Beispiel #1
0
    async def on_guild_member_remove(self, member: interactions.GuildMember):
        embed = interactions.Embed(
            title="User left",
            color=0xED4245,
            thumbnail=interactions.EmbedImageStruct(url=member.user.avatar_url, height=256, width=256)._json,
            author=interactions.EmbedAuthor(
                name=f"{member.user.username}#{member.user.discriminator}",
                icon_url=member.user.avatar_url,
            ),
            fields=[
                interactions.EmbedField(name="ID", value=str(member.user.id)),
                interactions.EmbedField(
                    name="Timestamps",
                    value="\n".join(
                        [
                            f"Joined: <t:{round(member.joined_at.timestamp())}:R>.",
                            f"Created: <t:{round(member.id.timestamp.timestamp())}:R>.",
                        ]
                    ),
                ),
            ]
        )
        _channel: dict = await self.bot._http.get_channel(src.const.METADATA["channels"]["mod-logs"])
        channel = interactions.Channel(**_channel, _client=self.bot._http)

        await channel.send(embeds=embed)
Beispiel #2
0
    async def _untimeout_member(self, ctx: interactions.CommandContext, member: interactions.Member, reason: str = "N/A"):
        """Untimeouts a member in the server and logs into the database."""
        await ctx.defer(ephemeral=True)
        db = self._actions
        id = len(list(db.items())) + 1
        action = src.model.Action(
            id=id,
            type=src.model.ActionType.TIMEOUT,
            moderator=ctx.author,
            user=member.user,
            reason=reason
        )
        db.update({str(id): action._json})
        self.actions.find_one_and_update({"id": MOD_ID}, {"$set": {"actions": db}})
        await self.get_actions()
        embed = interactions.Embed(
            title="User untimed out",
            color=0xFEE75C,
            author=interactions.EmbedAuthor(
                name=f"{member.user.username}#{member.user.discriminator}",
                icon_url=member.user.avatar_url,
            ),
            fields=[
                interactions.EmbedField(
                    name="Moderator",
                    value=f"{ctx.author.mention} ({ctx.author.user.username}#{ctx.author.user.discriminator})",
                    inline=True,
                ),
                interactions.EmbedField(
                    name="Timestamps",
                    value="\n".join(
                        [
                            f"Joined: <t:{round(member.joined_at.timestamp())}:R>.",
                            f"Created: <t:{round(member.id.timestamp.timestamp())}:R>.",
                        ]
                    ),
                ),
                interactions.EmbedField(name="Reason", value="N/A" if reason is None else reason),
            ]
        )
        _channel: dict = await self.bot._http.get_channel(src.const.METADATA["channels"]["action-logs"])
        channel = interactions.Channel(**_channel, _client=self.bot._http)

        if member.communication_disabled_until is None:
            return await ctx.send(f":x: {member.mention} is not timed out.", ephemeral=True)

        await member.modify(guild_id=ctx.guild_id, communication_disabled_until=None)
        await channel.send(embeds=embed)
        await ctx.send(f":heavy_check_mark: {member.mention} has been untimed out.", ephemeral=True)
Beispiel #3
0
    async def _kick_member(self, ctx: interactions.CommandContext, member: interactions.Member, reason: str = "N/A"):
        """Bans a member from the server and logs into the database."""
        await ctx.defer(ephemeral=True)
        db = self._actions
        id = len(list(db.items())) + 1
        action = src.model.Action(
            id=id,
            type=src.model.ActionType.KICK,
            moderator=ctx.author,
            user=member.user,
            reason=reason
        )
        db.update({str(id): action._json})
        self.actions.find_one_and_update({"id": MOD_ID}, {"$set": {"actions": db}})
        await self.get_actions()
        embed = interactions.Embed(
            title="User kicked",
            color=0xED4245,
            author=interactions.EmbedAuthor(
                name=f"{member.user.username}#{member.user.discriminator}",
                icon_url=member.user.avatar_url,
            ),
            fields=[
                interactions.EmbedField(
                    name="Moderator",
                    value=f"{ctx.author.mention} ({ctx.author.user.username}#{ctx.author.user.discriminator})",
                    inline=True,
                ),
                interactions.EmbedField(
                    name="Timestamps",
                    value="\n".join(
                        [
                            f"Joined: <t:{round(member.joined_at.timestamp())}:R>.",
                            f"Created: <t:{round(member.id.timestamp.timestamp())}:R>.",
                        ]
                    ),
                ),
                interactions.EmbedField(name="Reason", value=reason),
            ]
        )
        _channel: dict = await self.bot._http.get_channel(src.const.METADATA["channels"]["action-logs"])
        channel = interactions.Channel(**_channel, _client=self.bot._http)

        await member.kick(guild_id=src.const.METADATA["guild"], reason=reason)
        await channel.send(embeds=embed)
        await ctx.send(f":heavy_check_mark: {member.mention} has been kicked.", ephemeral=True)
Beispiel #4
0
    async def on_message_delete(self, message: interactions.Message):
        embed = interactions.Embed(
            title="Message deleted",
            color=0xED4245,
            author=interactions.EmbedAuthor(
                name=f"{message.author.username}#{message.author.discriminator}",
                icon_url=message.author.avatar_url
            ),
            fields=[
                interactions.EmbedField(name="ID", value=str(message.author.id), inline=True),
                interactions.EmbedField(
                    name="Message",
                    value=message.content if message.content else "**Message could not be retrieved.**"
                ),
            ],
        )
        _channel: dict = await self.bot._http.get_channel(src.const.METADATA["channels"]["mod-logs"])
        channel = interactions.Channel(**_channel, _client=self.bot._http)

        await channel.send(embeds=embed)
Beispiel #5
0
    async def _unban_member(self, ctx: interactions.CommandContext, id: int, reason: str = "N/A"):
        """Unbans a user from the server and logs into the database."""
        await ctx.defer(ephemeral=True)
        db = self._actions
        _id = len(list(db.items())) + 1
        _user: dict = await self.bot._http.get_user(id=id)
        user = interactions.User(**_user)
        action = src.model.Action(
            id=_id,
            type=src.model.ActionType.KICK,
            moderator=ctx.author,
            user=user,
            reason=reason
        )
        db.update({str(_id): action._json})
        self.actions.find_one_and_update({"id": MOD_ID}, {"$set": {"actions": db}})
        await self.get_actions()
        embed = interactions.Embed(
            title="User unbanned",
            color=0x57F287,
            author=interactions.EmbedAuthor(
                name=f"{user.username}#{user.discriminator}",
                icon_url=user.avatar_url,
            ),
            fields=[
                interactions.EmbedField(
                    name="Moderator",
                    value=f"{ctx.author.mention} ({ctx.author.user.username}#{ctx.author.user.discriminator})",
                    inline=True,
                ),
                interactions.EmbedField(name="Reason", value=reason),
            ]
        )
        _guild: dict = await self.bot._http.get_guild(src.const.METADATA["guild"])
        guild = interactions.Guild(**_guild, _client=self.bot._http)
        _channel: dict = await self.bot._http.get_channel(src.const.METADATA["channels"]["action-logs"])
        channel = interactions.Channel(**_channel, _client=self.bot._http)

        await guild.remove_ban(user_id=id, reason=reason)
        await channel.send(embeds=embed)
        await ctx.send(f":heavy_check_mark: {user.mention} has been unbanned.", ephemeral=True)
Beispiel #6
0
 async def get_user_info(self, ctx: interactions.CommandContext):
     embed = interactions.Embed(
         title="User Information",
         description="This is the retrieved information on the user.",
         thumbnail=interactions.EmbedImageStruct(
             url=ctx.target.user.avatar_url, height=256, width=256)._json,
         author=interactions.EmbedAuthor(
             name=f"{ctx.target.user.username}",
             url=f"https://discord.com/users/{ctx.target.user.id}",
             icon_url=ctx.target.user.avatar_url,
         ),
         fields=[
             interactions.EmbedField(
                 name="Username",
                 value=
                 f"{ctx.target.user.username}#{ctx.target.user.discriminator}",
                 inline=True,
             ),
             interactions.EmbedField(name="ID",
                                     value=str(ctx.target.user.id),
                                     inline=True),
             interactions.EmbedField(
                 name="Timestamps",
                 value="\n".join([
                     f"Joined: <t:{round(ctx.target.joined_at.timestamp())}:R>.",
                     f"Created: <t:{round(ctx.target.id.timestamp.timestamp())}:R>.",
                 ]),
                 inline=True,
             ),
             interactions.EmbedField(
                 name="Roles",
                 value=(", ".join([
                     f"<@&{role}>" for role in ctx.target.roles
                 ]) if isinstance(ctx.target, interactions.Member)
                        and ctx.target.roles else "`N/A`"),
             ),
         ],
     )
     await ctx.send(embeds=embed, ephemeral=True)