import discord
import asyncio
from discord.ext import commands
description = "desc"
bot = commands.Bot(command_prefix='?', description=description)
#startup command
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print(' ')
#category of main commands
class Main_Commands():
def __init__(self, bot):
self.bot = bot
#ping command test
@bot.command(pass_context=True)
async def ping(ctx):
await bot.say("pong")
#when the user types in ?ping, the bot will return "pong"
#This is an example of a simple command in this language
#RunBot
bot.run("TOKEN GOES HERE")
# (C) 2017
# All rights reserved
# Any part of this program may be used and/or modified at the users discretion
;
这是一个相当冗长的回答,但我建议阅读整件事。在
StackExchange是一个人们发布和讨论代码的社区。恕我直言,我可以向您保证,如果我们看不到您尝试过的代码或任何现有代码,这里没有人(包括我)会为您编写代码。在
如果你有一个相关的产品,人们可以在这个网站上查找错误和/或帮助你建立它,你一定会有更好的运气。在
同时,请在此处查看非官方用户不一致API服务器:https://discordapp.com/invite/discord-API
当我处在你的位置时,这个discord服务器对于回答任何关于discord API的问题非常有帮助,因为那里99.9%的人都知道你的问题是什么以及如何解决它。当你构建代码时,人们总是在线回答你的问题。在
如果您需要启动代码的帮助,基本步骤如下:
因为我不知道到目前为止您在bot上取得了什么进展,我只是用python编写了一些线框代码来开始。在
import discord import asyncio from discord.ext import commands description = "desc" bot = commands.Bot(command_prefix='?', description=description) #startup command @bot.event async def on_ready(): print('Logged in as') print(bot.user.name) print(bot.user.id) print(' ') #category of main commands class Main_Commands(): def __init__(self, bot): self.bot = bot #ping command test @bot.command(pass_context=True) async def ping(ctx): await bot.say("pong") #when the user types in ?ping, the bot will return "pong" #This is an example of a simple command in this language #RunBot bot.run("TOKEN GOES HERE") # (C) 2017 # All rights reserved # Any part of this program may be used and/or modified at the users discretion
;不管怎样,我希望这个回答对你有帮助。如果您需要我的帮助,请随时给我发邮件,告诉我不和谐的事,我会尽量在我的日程安排允许的时候回复。在
编码快乐!!在
{a3}检查API的引用