我正在尝试打印出我的机器人所在的所有服务器中所有成员的名称。这是我的代码: @bot.event
async def on_ready():
await bot.wait_until_ready()
for guild in bot.guilds:
print(guild.name)
for member in guild.members:
print(member.name) 这将打印所有的行会名称,但只打印机器人自己的名称,我该如何解决这个问题?
我正在使用Replit制造一个不和谐的机器人。
if msgtxt in listBadWords:
await message.channel.send(mention + ", your message has been reported to Arunga")
await message.channel.send("Please do not repeat the same mistake again. Do not say bad words!")
user = client.get_user(int(userid))
对于一个命令,我尝试将每个成员从一个特定类别中的每个频道移动到另一个频道,并删除该类别中的所有频道。我已经测试了代码,除了channel.members部分之外,所有的代码都可以正常工作。每次我运行该命令时,print(channel.members)都会返回一个空的列表[]。知道我做错了什么吗? 我知道获取行会ID会阻止这项工作,但我不会在代码中的任何地方这样做。 #Delete all channels in Ongoing Matches
@client.command()
async def comm(ctx):
general = discord.utils.get(ctx
我正在尝试创建一个命令,为公会中的每个实际用户指定一个特定的角色,但不包括机器人。我有以下代码: @commands.command()
@commands.has_permissions(manage_roles=True)
async def maddrole(self,ctx,role: discord.Role):
guild = ctx.guild
for member in guild.members:
await member.add_roles(role)
embed= disco
导入这个类:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "MyMsgBox"
Attribute VB_PredeclaredId = True
Public Function Show(testo As String) as Boolean
Attribute Show.VB_UserMemId = 0
msgbox testo
Show = True
End Function
并在模块中执行以下代码:
MyMsgBox.Show "hi
很抱歉打扰到大家,我知道这是重复的,但是我没有资格发表评论,所以我不得不再问一次,我看到了一些关于这个问题的其他帖子,他们都说您手动获得了行会id,并在on_ready()中定义了它,比如:
@bot.event
async def on_ready():
guild = bot.get_guild(ID_OF_GUILD) # find ID by right clicking on server icon and choosing "copy id" at the bottom
if guild.get_member(ID_OF_MEMBER) is not
我使用一个json文件来存储行会的星板频道。下面是我的代码: @client.event
async def on_raw_reaction_add(payload):
star = await get_star_channels()
if str(payload.message.guild.id) not in star:
return
starchannel = client.get_channel(star[str(payload.message.guild.id)])
if payload.emoji == &
所以,大家好,这里的问题是,我希望我的机器人DM我加入一个服务器,目前,我正在使用这个代码,它不工作,但它也没有给我任何错误。
@client.event
async def on_guild_join(guild):
print(f"bot has joined {client.guild.name} and we have {len(client.guilds)} servers")
user = discord.User(my_user_id)
await user.send(f"bot has joined {client.guild.name}
我正试着制造我的第一个机器人来解决不和。我想要实现的是获取服务器中所有角色的颜色。我怎么能这么做?我搜索,但我只发现如何设置一个角色的颜色,而不是如何获得当前的颜色。提前感谢您的帮助。
@client.command()
async def roles_colors(ctx):
for role in ctx.guild.roles:
await ctx.send(role.name)
await ctx.send(discord.role.color)
我想获得discord.py中附加到消息的图像的高度。这是我的代码:
if message.content(discord.Attachment.height > 0):
await message.channel.send('Your media file is restricted!')
运行时,它会给出以下错误:
error: TypeError: '>' not supported between instances of 'member_descriptor' and 'int'
如何获得消息中提到的用户的id?我正在尝试执行一个命令,其中需要命令中提到的用户id。到目前为止,我的代码如下:
@commands.command()
async def fight(self, ctx):
# Send command message
await ctx.send('You need to tag someone: .fight @user')
if user.mention in ctx.content:
if user.mention == self.client.user:
await