【发布时间】:2020-03-19 15:05:41
【问题描述】:
好的,我有这段代码,但是当我尝试使用 $announce 时,它不会回写 Hello。事实上,它没有响应我放在 async def 下的任何内容。怎么会?
我觉得我所做的一切都是正确的,并且这些教程是用于重写和我正在使用的。
import discord
from discord.ext import commands
import os
import time
import random
import weather
from weather import Weather, Unit
prefix = '$'
client = commands.Bot(command_prefix = prefix)
clattr = discord.Client()
@client.event
async def on_ready():
await client.change_presence(status = discord.Status.online, activity = discord.Game('have a nice day!'))
print("Bot is now online!")
@client.event
async def on_message(message):
if message.content.startswith("$hello"):
await message.channel.send(f"""Hi""")
await message.channel.send(f"""Hi""")
await message.channel.send(f"""Hi""")
await message.channel.send(f"""Hi""")
await message.channel.send(f"""Hi""")
await message.channel.send(f"""Hi""")
await message.channel.send(time())
if message.content.startswith("$dm"):
user = client.get_user(393921960817721355)
dm_channel = user.dm_channel
if (dm_channel==None):
dm_channel = await user.create_dm()
await dm_channel.send(f"""Hello!""")
if message.content.startswith("$servers"):
await message.channel.send(clattr.guilds)
if message.content.startswith("$help"):
await message.channel.send(f"""This is the vanceBot. Made by vance and OYOHO#5964 (xray#4398 helped as well).\nThese are the current commands:\n$hello, which says "Hi" a few times \n$dm, which DMs a person\n$servers, which displays the number of servers that the bot is on\n$leave, to get the bot to leave\n$help, this command.\nThe prefix is $.""")
if message.content.startswith("$pinghelp"):
await message.channel.send(f"""||@everyone|| This is the vanceBot. Made by vance and OYOHO#5964 (xray#4398 helped as well).\nThese are the current commands:\n$hello, which says "Hi" a few times \n$dm, which DMs a person\n$servers, which displays the number of servers that the bot is on\n$leave, to get the bot to leave\n$help, this command.\nThe prefix is $.""")
@client.command()
async def announce(ctx, announcement):
await ctx.send(f"""Hello""")
TOKEN = os.environ.get("DISCORD_BOT_SECRET")
client.run(TOKEN)
【问题讨论】:
标签: python discord.py discord.py-rewrite