我正试着制作一个机器人,当你输入一个命令时,它会给你一个角色,我已经试着让角色部分工作了很长一段时间了,但是我总是在错误之后出错--这是我的当前代码-
@bot.command(name= 'playfata')
async def playfata(ctx):
member = ctx.author
role = discord.utils.get(member.guild.roles, name="Currently Playing")
if role in member.roles:
await ctx.send(&
如何检查特定渠道中的默认角色拥有哪些权限?
我试过了:
if member.default_role.permission_in(channel).send_message:
但是,如果没有错误消息,它将无法工作。我试过的其他方法也都不起作用。
下面是我的代码:
@commands.command()
async def unmute(self, ctx, member: discord.Member):
if ctx.author.guild_permissions.kick_members:
for channel in ctx.guild.text_channel
我刚开始做一个不和谐的机器人。我想做一个命令,你可以输入-queue duos与其他人谁也想排队游戏。但是,我的添加角色命令完全没有响应,当我在Discord中键入命令时,也不会给出角色或错误。
import discord
import os
#run the Bot and a message to make sure it ran
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
新的discord.py-在这里重写用户。 我正在编写一个具有不一致接口的机器人:它连接到多个服务器(公会),目前我需要一个身份验证系统来限制它的使用。我认为我可以获取所有用户的角色,并在以后需要时对其进行解析。所以我就这么做了: @client.event
async def on_ready():
...
for guild in client.guilds:
for member in guild.members:
for role in member.roles:
我只是想让我的机器人在不和谐的情况下给用户添加一个角色。虽然语法看起来很简单,但显然我做错了一些事情,我对python还不熟悉,所以我希望有一些指向正确方向的提示!
bot = commands.Bot(command_prefix='!')
def getdiscordid(discordname):
for guild in bot.guilds:
for member in guild.members:
if member.name == discordname:
return member
除了使用discord.py的admin之外,我如何隐藏除一个之外的所有通道(可以用角色id或名称排除该通道)。
hide all channels except one (by making it private) with a command
Return all channels back to normal with a command
我正在制作一个反应角色频道,如果你用一个表情符号进行反应,它会给你相应的角色。我在我的验证系统中使用了完全相同的代码,它工作得很好。但由于某种原因,当我用相应的表情符号回应这条消息时,我没有得到角色,没有回溯显示,也没有在控制台上收到“给了某人一个角色”的消息。
代码:
async def roles(ctx):
embed=discord.Embed(title="Reaction Roles", description="React with the corresponding emoji to get the role", color=0xff0000