【发布时间】:2021-12-07 06:00:00
【问题描述】:
我想成为一个假的不和谐机器人,所以我可以使用:!!send 或类似的东西。
我已经准备好令牌,我尝试了一些 repl.it 模板,但我不知道该怎么做。
这是我尝试过的代码:
import discord
import os
import time
import discord.ext
from discord.utils import get
from discord.ext import commands, tasks
from discord.ext.commands import has_permissions, CheckFailure, check
os.environ["TOKEN"] = "no-token-for-you-to-see-here"
#^ basic imports for other features of discord.py and python ^
client = discord.Client()
client = commands.Bot(command_prefix = '!!') #put your own prefix here
@client.event
async def on_ready():
print("bot online") #will print "bot online" in the console when the bot is online
@client.command(pass_context=True)
async def send(ctx,*,message):
await client.say(message)
client.run(os.getenv("TOKEN")) #get your bot token and create a key named `TOKEN` to the secrets panel then paste your bot token as the value.
#to keep your bot from shutting down use https://uptimerobot.com then create a https:// monitor and put the link to the website that appewars when you run this repl in the monitor and it will keep your bot alive by pinging the flask server
#enjoy!
在线,但命令不起作用。
【问题讨论】:
-
你好!你有任何minimum, reproducible examples 可以给我们看吗?如果没有看到您首先尝试过的东西,我们无法给您答案。请访问how-to-ask 以获得进一步的帮助。祝你好运!
-
@Bagle 好的,我把我用的代码放上去。
标签: python-3.x discord discord.py bots