到目前为止,这是我的代码,我在存在问题的那部分发表了评论。 等待message.channel.send可以正常工作,但是当我使用bot命令发送消息时,它没有给出错误,但在聊天中不发送任何内容。谢谢!
import discord
from discord.ext import commands
import os
from random import randint
import coinflipper
###Discord.py Def###
client = discord.Client()
channel = client.get_channel
bot = commands.Bot(command_prefix='!')
###Print When Ready###
@client.event
async def on_ready():
print("Bot Is Online!")
###Make the Bot not Respond to its self###
@client.event
async def on_message(message):
print(message.content)
print(message.channel)
if message.author == client.user:
return
###Respond to Messages###
if message.content == "ping":
await message.channel.send("Pong!")
###Coin Flipper Game###
if message.content == "coin":
if coinflipper.coin() == True:
await message.channel.send("It's Heads!")
else:
await message.channel.send("It's Tails")
###Having Trouble Here###
@bot.command(pass_context=True)
async def test(ctx):
await ctx.send('test')
##############################
###Discord Bot API Token###
client.run("TOKEN")```