【发布时间】:2021-06-14 20:07:52
【问题描述】:
我是 Python 和 StackOver 流的新手。我正在为我的公会编写一个 Discord Bot。我要添加的第一个功能是在特定频道中发送欢迎消息。我对其进行了编码,运行时没有出现错误……但是当有人加入我的服务器时,机器人没有发送任何消息。
这是我的代码:
from discord.ext import commands
import discord
bot = commands.Bot(command_prefix='-')
TOKEN = '<Bot Token>'
@bot.event
async def on_ready():
print("Succesfully logged in as {0.user}".format(bot))
@bot.event
async def on_memeber_join(member):
try:
channel = bot.get_channel(<Channel ID>)
await channel.message.send(
'Welcome to PRIME CLUB {0.mention}'.format(member))
except Exception as e:
print(e)
bot.run(TOKEN)
请帮助我纠正我的错误... 提前感谢
【问题讨论】:
标签: discord.py python-3.8