我编写了一个代码,这里是:
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
async def on_message(self, message):
# we do not want the bot to reply to itself
if message.author.id == self.user.id:
return
if message.content.startswith('Hello'):
await message.channel.send('Hello {0.author.mention}'.format(message))
if message.content.startswith('G!Help'):
await message.channel.send('Hello {0.author.mention} Here are some commands you can use: Who, Yeet, Why, Help'.format(message))
if message.content.startswith('G!Who'):
await message.channel.send('You are {0.author.mention} WOW!'.format(message))
if message.content.startswith('G!Yeet'):
await message.channel.send('{0.author.mention} Yeet!'.format(message))
if message.content.startswith('G!Why'):
await message.channel.send('Erm, {0.author.mention} Why What?'.format(message))
client = MyClient()
client.run('Insert token here')
很抱歉格式化,所以网站就是这样
if message.content.startswith('G!Help'):
await message.channel.send('Hello {0.author.mention} Here are some commands you can use: Who, Yeet, Why, Help'.format(message)) to if message.content.startswith('G!Why'):
await message.channel.send('Erm, {0.author.mention} Why What?'.format(message))
它不起作用,有帮助吗?还有插入令牌 东西有令牌,只是我删除了它,因为我不想泄漏它,非常感谢帮助。
答案 0 :(得分:0)
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
async def on_message(self, message):
# we do not want the bot to reply to itself
if message.author.id == self.user.id:
return
if message.content.startswith('Hello'):
await message.channel.send('Hello {0.author.mention}'.format(message))
elif message.content.startswith('G!Help'):
await message.channel.send('Hello {0.author.mention} Here are some commands you can use: Who, Yeet, Why, Help'.format(message))