Discord.py | 我正在尝试使用会员名称和会员ID禁止我的漫游器

xXSkillexZ

我的代码(嵌齿轮内):

import discord
import datetime
from discord.ext import commands

class unban(commands.Cog):

    def __init__(self, client):
        self.client = client

    @commands.command()
    @commands.has_permissions(ban_members = True)
    async def unban(self, ctx, id: int):
        user = await self.client.fetch_user(id)
        await ctx.guild.unban(user)

        unban= discord.Embed(title=f'A moderation action has been performed!', description='', color=0x90fd05)
        #unban.add_field(name='User Affected:', value=f'`{member.name}`', inline=True)
        #unban.add_field(name='User ID:', value=f'`{member.id}`', inline=True)
        unban.add_field(name='Moderator Name:', value=f'`{ctx.author}`', inline=True)
        unban.add_field(name='Moderator ID:', value=f'`{ctx.author.id}`', inline=True)
        unban.add_field(name='Action Performed:', value='`UnBan`', inline=True)
        unban.set_author(name=f'{ctx.guild}', icon_url=ctx.guild.icon_url)
        #unban.set_thumbnail(url=member.avatar_url)
        unban.timestamp = datetime.datetime.utcnow()

        await ctx.send(embed=unban)
        
        
def setup(client):
    client.add_cog(unban(client))

我已发出命令,因此我可以禁止其他人。但是我只能取消他们的ID。我也希望它的名字也不受限制。那我该怎么办呢?

我也尝试过更换:

async def unban(self, ctx, id: int):

与:

async def unban(self, ctx, member : discord.Member):

但没有任何效果。并且我尝试同时使用:

async def unban(self, ctx, member : discord.Member, id: int):

但还是没用...

助焊剂
async def unban(self, ctx, member : discord.Member):

由于被禁止的会员只能discord.User由ID或由ID代表,因此无法使用

async def unban(self, ctx, user_id : int):
    user = await self.client.fetch_user(user_id)
    await ctx.guild.unban(user)

这仅适用于ID,因此不一致的用户可以在其数据库中找到用户。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章