massdm.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:tmerc-cogs 作者: tmercswims 项目源码 文件源码
def _mdm(self, ctx: commands.Context,
                   role: discord.Role, *, message: str):
        """Sends a DM to all Members with the given Role.
        Allows for the following customizations:
        {0} is the member being messaged.
        {1} is the role they are being message through.
        {2} is the person sending the message.
        """

        server = ctx.message.server
        sender = ctx.message.author

        try:
            await self.bot.delete_message(ctx.message)
        except:
            pass

        dm_these = self._get_users_with_role(server, role)

        for user in dm_these:
            try:
                await self.bot.send_message(user,
                                            message.format(user, role, sender))
            except (discord.Forbidden, discord.HTTPException):
                continue
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号