嗨,所以我想做的就是向我的机器人在我的代码中的所有服务器发送一条消息,我很确定这不是反对的,但如果是的话,请纠正我
await bot.wait_until_ready()
channels = []
for server in client.servers:
for channel in server.channels:
channels.append(channel)
Message.send('HELLO! and thank you for adding this amazing bot. yes i am the owner ELONI sending this message saying thanks. thanks for getting us verified thanks for everythng. have a great DAY')
答案 0 :(得分:0)
for guild in client.guilds: # guild stands for server
for channel in guild.channels:
if isinstance(channel, discord.TextChannel): # Check if channel is a text channel
await channel.send("Hi")
如果使用Discord.py-Rewrite,则可以将其添加到事件或命令中。
示例事件:
@client.event
async def on_ready():
for guild in client.guilds: # guild stands for server
for channel in guild.channels:
if isinstance(channel, discord.TextChannel): # Check if channel is a text channel
await channel.send("Hi")
示例命令:
@client.command()
async def ping(ctx):
for guild in client.guilds: # guild stands for server
for channel in guild.channels:
if isinstance(channel, discord.TextChannel): # Check if channel is a text channel
await channel.send("Hi")