コード例 #1
0
 async def callback(self, response: discord.SlashCommandResponse):
     detected_urls = await detect_bad_domains(response.options.content)
     if len(detected_urls) != 0:
         embed = ErrorEmbed(title='SCAM/PHISHING/ADULT LINK(S) DETECTED')
         detected_string = '\n'.join(
             [f'- ||{i}||' for i in set(detected_urls)])
         embed.description = f'The following scam url(s) were detected:\n{detected_string}'
         embed.set_author(
             name=response.interaction.user.display_name,
             icon_url=response.interaction.user.display_avatar.url)
         await response.send_message(embed=embed, ephemeral=True)
         return
     await response.send_message(
         embed=SuccessEmbed(title="The url or the text message is safe!"),
         ephemeral=True)
コード例 #2
0
    async def feedback(self, ctx, *, feed):
        """
        Sends your feedback about the server to the server owner. (This can only be done if it is enabled by the server admin)
        ``The feedback should be less than 2000 characters``
        """
        if not await ctx.prompt(
                "Are you sure that you want to **send the feedback** ?",
                author_id=ctx.author.id,
        ):
            return

        if len(feed) > 2000:
            await ctx.send(
                "\N{WARNING SIGN} The feedback should be less than 2000 characters"
            )
            return
        data = await (await self.database_class()).get(ctx.guild.id)
        if data is None or data.get("feedback") is None:
            e = ErrorEmbed(
                title="No Feedback system setup for this server!",
                description=
                "An admin can always setup the **feedback system** using `{}setup add feedback #channelname` command"
                .format(ctx.prefix),
            )
            await ctx.send(embed=e, delete_after=10)
            return

        channel = self.bot.get_channel(data.get("feedback"))

        e = Embed(
            title="Feedback sent!",
            description=f"Your feedback '{feed}' has been sent!",
        )
        await ctx.send(embed=e, delete_after=10)

        e2 = discord.Embed(
            title="New Feedback!",
            description=feed,
            colour=ctx.author.color or ctx.author.top_role.colour.value
            or discord.Color.random(),
        )
        e2.set_author(name=ctx.author.display_name,
                      icon_url=ctx.author.display_avatar.url)
        e.set_author(name=ctx.author.display_name,
                     icon_url=ctx.author.display_avatar.url)
        await channel.send(embed=e2)