我制作了一个代码,这里是:
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))
它不起作用,有帮助吗?和插入的令牌 东西有一个令牌,只是我删除了它,因为我不想泄漏它,帮助您非常感谢。
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))