我尝试创建一个不和谐的机器人,但我失败了很多次,这是我最近的尝试...
import discord
from discord.ext.commands import Bot
from discord.ext import commands
print("This might take a few seconds")
print("Please wait...\n\n")
client = discord.Client()
bot = commands.Bot(command_prefix='/')
@client.event
async def on_ready():
activity = discord.Game(name="test", type=3)
await bot.change_presence(status=discord.Status.idle, activity=activity)
print("Bot Online!\n")
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('secret'):
await message.channel.send('What is the "secret" you speak of?')
if ctx.invoked_subcommand is None:
await message.channel.send('Shh!', delete_after=5)
client.run('XXXXXXXXXXXXXXX')
我什至无法通过雕像部分。我想做的是一个拥有经济(商店和银行)的机器人。有人可以帮我吗
答案 0 :(得分:1)
正如@Joshua Nixon 所说,您应该使用 commands.Bot
而不是 discord.Client
(docs)
要存储所有信息,您可以使用 json、sqlite 或 mongoDB 之类的东西作为数据库