Kat*_*sha -4 python discord discord.py
我正在编写一个不和谐的机器人程序,对于其中一个命令,我希望机器人能够 ping 发送该命令的用户。我正在使用 python 3.6.6
以下是如何 ping(提及)发送特定消息(命令)的用户的示例:
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == '$the_ping_cmd':
await message.channel.send('Pinging {}'.format(message.author.mention))
client = MyClient()
client.run('token')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16303 次 |
| 最近记录: |