【发布时间】:2022-07-09 23:11:07
【问题描述】:
从第 35 行开始,机器人应该检测到消息并在控制台中打印,但它不会在控制台中打印消息。
我已尝试寻找解决方案,但我尝试的每个解决方案都不起作用。我做错了吗?
import discord
from discord import channel
from discord import message
from discord.colour import Color
from discord.errors import PrivilegedIntentsRequired
from discord.ext import commands
token = token
client = commands.Bot(command_prefix="<", case_insensitive=True)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.command()
async def clear(ctx, amount=100):
await ctx.channel.purge(limit=amount)
@client.command()
async def move(ctx,member: discord.Member=None, VoiceChannel=None):
try:
channel = discord.utils.get(ctx.guild.channels, id=int(VoiceChannel))
if member == None:
await ctx.message.author.move_to(channel)
else:
await member.move_to(channel)
except Exception as e:
embed = discord.Embed(
title = '**ERROR**',
description = 'e',
colour = discord.Color.red()
)
await ctx.send(embed=embed)
@client.event
async def on_message(message):
print(message.content)
@client.event
async def on_message(message):
ctx = await client.get_context(message)
if ctx.valid:
await client.invoke(ctx)
client.run(token)
【问题讨论】:
标签: python discord.py