我正在编写一种方法,让用户在discord.py中扮演每个角色,我想知道是否有一种方法可以忽略机器人角色,例如:
@Eagle.command()
async def giveroles(ctx,member:discord.Member):
roleappend = []
for role in ctx.guild.roles:
roleappend.append(role)
await member.edit(roles=roleappend)
await sendembed(ctx,"Give All Role",f"
我在父模型payment上有一个表单集invoice。如果用户输入付款,但忘记付款日期(这是必需的),页面仍然保存发票和,然后关闭。
我从form_valid中可以看出formset.is_valid()是假的。如果我在控制台:[{}, {}, {'paymentdate': ['This field is required.']}, {}]中打印错误,就会看到错误。在关闭之前,我甚至可以在页面上看到验证显示。
当存在验证错误时,如何防止页面关闭?
我试图执行一个info命令,正如您可以看到的那样,但是在角色部分,我不能显示用户的角色。起初,我执行了一个工作命令,但是它也显示了"@everyone“角色,所以我做了一个字符串来删除它(mention.remove("everyone")),但是它不能工作--它给出了一个错误:
Command raised an exception: ValueError: list.remove(x): x not in list
我也试着用“每个人”来代替“每个人”,但它仍然不起作用。
@client.command()
async def info(ctx, user: dis
我想在我的服务器上做一个禁令上诉系统。我想删除某人的每一个角色,并赋予他们[Banned]角色。我不能就像我对所有成员角色所做的那样,因为有很多角色,甚至是一些每天都被创建和删除的自定义角色。
member_role = get(user.guild.roles, name="『✅』· ")
await user.remove_roles(member_role, reason=None, atomic=True)
我试过这样做:,但没有成功。也尝试过这样做:
for role in user.roles:
if role.name == '[Banned]
我只是想让我的机器人在不和谐的情况下给用户添加一个角色。虽然语法看起来很简单,但显然我做错了一些事情,我对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
我正试着制作一个机器人,当你输入一个命令时,它会给你一个角色,我已经试着让角色部分工作了很长一段时间了,但是我总是在错误之后出错--这是我的当前代码-
@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(&
我刚开始做一个不和谐的机器人。我想做一个命令,你可以输入-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))
我正在开发一个机器人。对于某个齿轮,我希望创建一个自定义的检查装饰器,用于检查运行命令的人是否具有特定的角色。角色作为实例变量存储为角色类。当我尝试运行它时,它不工作。你是怎么做这个装饰品的? class Moderation(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.mod_role = None # Assume there's already a role here
class Decorator:
@cl
我试图用python编写一个不和谐的机器人,在这个命令中,您可以通过键入类似;me的内容来获取/删除一个角色。所以,如果你已经有了这个角色,它会删除它,如果你没有这个角色,它会给你这个角色,但它不起作用。控制台中不会出现任何错误,我的机器人不会回复命令,也不会给/删除角色。有人能帮忙吗?
@client.command()
async def me(ctx):
role=client.get_role(123456789)
if role in ctx.author.roles:
em1=discord.Embed(description="I have have re
我正在制作一个反应角色频道,如果你用一个表情符号进行反应,它会给你相应的角色。我在我的验证系统中使用了完全相同的代码,它工作得很好。但由于某种原因,当我用相应的表情符号回应这条消息时,我没有得到角色,没有回溯显示,也没有在控制台上收到“给了某人一个角色”的消息。
代码:
async def roles(ctx):
embed=discord.Embed(title="Reaction Roles", description="React with the corresponding emoji to get the role", color=0xff0000