import discord
from discord.ext import commands
import asyncio
import time
client= commands.Bot(command_prefix= '.')
@client.event
async def on_ready():
for a in client.get_all_members():
time.sleep(1)
print(a) 这段代码给了我之前服务器的成员,允许我为成员创建DM,但几天前它停止工作,现在只打印我的机器人名称。
我有一段代码可以从服务器上的每个人中删除一个角色,但它不起作用:当我输入命令时,bot会忽略它,cmd中没有任何内容,bot也不会做任何事情 代码- intents = discord.Intents()
intents.members = True
@client.command()
async def clearrole(ctx):
role = discord.utils.get(ctx.guild.roles, id = 795410455848812565)
members = ctx.guild.members
for mem
所以现在我的设置是 if memb.id != 'EzLife#9391' and memb.id != message.guild.owner.id and memb.top_role < client.top_role: 但问题是,客户端是一个机器人,机器人没有顶层角色。我试图通过做client.me.top_role来获得机器人的成员,但我没有得到任何高级角色。有什么修复方法吗?
我是说头衔说明了一切。 我如何从这个“成员”命令中获取id?当特定的人加入vc时,我正在尝试向通道发送消息。但我不知道如何获得加入vc的人的id。我阅读了一些关于这方面的文档,所有这些文档都像message.author.id或smth。我是个新手。考虑解释一下:) @client.event
async def on_voice_state_update(member, before, after):
if not before.channel and after.channel:
channel = client.get_channel("channel id here
我目前正在编写一个机器人,我的第一个目标是让机器人欢迎,并向加入或离开的成员说再见,但机器人什么也不发送,甚至不显示任何错误。 @client.event
async def on_member_join(member):
print(" System: A member has joined the server!")
def sprint(str):
for c in str + '\n':
sys.stdout.write(c)
sys.stdout.flush()
我正在尝试创建一个Zalgofyes成员用户名的命令,当他们使用该命令时,我遇到了问题我正在使用python库zalgo_text,这是代码 async def fmsu(ctx):
await ctx.author.edit(nick=zalgo.zalgo().zalgofy(ctx.author)),
await ctx.send("Your username has been Zalgofyed {0.author.mention}".format(ctx.message))```
When I use the command I get th
@client.command()
async def find(ctx):
guild = ctx.message.guild
role = discord.utils.get(ctx.guild.roles,name="Palpatin")
for member in guild.members:
if role in member.roles :
await ctx.send(f'{member}')
await member.remove_roles(role) 当
在不一致上测试时不能运行的函数是on_messages。其余的都运行得很好!我想这可能是因为我没有调用这个函数,但我也没有在最后一个函数on_message中调用它,"you rang?“--这很好用。 比较第一个函数和最后一个函数,我在那里做了什么不同,最后一个运行而不是第一个? import discord
import os
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
import random
Client = discord
我用python编写了一个不和谐的机器人,它一直工作到今天。今天,它找不到我的服务器的成员,这显然是一个交易破坏。为了确定故障点,我编写了以下测试例程: @bot.command(name='test', help='test stuff')
async def test(ctx):
for guild in bot.guilds:
for member in guild.members:
print(member)
print("Test done") 这是我从文档中复制并粘贴的代码,