# 需要导入模块: from discord import Client [as 别名]# 或者: from discord.Client importsend_message[as 别名]defhandle_playing(c:discord.Client, message:discord.Message, command:list, pref:Preferences):iflen(command) ==4: pref.addGameSaying(command[2], command[3])yieldfromc.send_message(mess...
# 需要导入模块: import discord [as 别名]# 或者: from discord importMessage[as 别名]defsend_header(self, msg:Message)->None:"""Sends a header embed with information about the relayed messages to the watch channel."""user_id = msg.author.id guild = self.bot.get_guild(GuildConfig.id) a...
要获取消息的消息内容,您需要message_contentIntent。这是一个特权Intent。要启用它,请在Discord开发者...
I would like to send a message in a specific text channel no matter on which server, so I cannot hard-code the ID of my channel. This part of the code is working : But my problem is this part witch is in a Cog : I got this error : I tried a lot of thi
您必须使用 send_message 方法。在此之前,你必须找到哪个 User 对应于你自己。 @client.event async def on_message(message): # we do not want the bot to reply to itself if message.author == client.user: return # can be cached... me = await client.get_user_info('MY_SNOWFLAKE_ID') awai...
当机器人通过on_message接收消息时,只有一个参数: message。它是一个完全独立的类,但它可以分解为:...
您需要以某种方式确定每个传入消息需要使用哪个pool。您有两个选择:要么尝试每个池,直到其中一个工作,...
import discord from discord.ext import commands 创建一个Discord bot实例: 代码语言:txt 复制 bot = commands.Bot(command_prefix='!') 创建一个命令来发送附件。可以使用@bot.command()装饰器来定义一个命令: 代码语言:txt 复制 @bot.command() async def send_attachment(ctx): # 获取附件文件 file = di...
import discord import asyncio client = discord.Client() @client.event async def on_ready(): print('Logged in as') print(client.user.name) print(client.user.id) print('---') @client.event async def on_message(message): if message.content.startswith('!test'): counter = 0 tmp = awai...
await message.channel.send(F"不讲武德der {menber} 退出了,我劝你耗子尾汁") 1. 2. 3. 4. 5. 6. 7. 8. 最后,代码会是这样子的: import discord from discord.ext import commands client = discord.Client() bot = discord.ext.commands.Bot(command_prefix = "your_prefix"); ...