该机器人在私人消息中工作正常,但在任何情况下都不能在频道上工作。所有权利都是在受邀时授予的,甚至是在频道本身上授予的,没有任何限制,无论哪个频道都没有关系。
请帮我解决这个问题,它对我不起作用。
代码示例:
import discord
import json
import requests
from discord.ext import commands
bot = commands.Bot(command_prefix = '/')
@bot.event
async def on_ready():
print('Я готов')
@bot.command()
async def hello(ctx):
await ctx.send('Test10')
@bot.command()
async def nya(ctx):
await ctx.send('Hello there')
@bot.command()
async def hello2(ctx):
author = ctx.message.author
await ctx.send(f'Hello, {author.mention}!')
@bot.command()
async def fox(ctx):
response = requests.get('https://some-random-api.ml/img/fox') # Get-запрос
json_data = json.loads(response.text) # Извлекаем JSON
embed = discord.Embed(color = 0xff9900, title = 'Random Fox') # Создание Embed'a
embed.set_image(url = json_data['link']) # Устанавливаем картинку Embed'a
await ctx.send(embed = embed) # Отправляем Embed
bot.run('Здесь токен')
在顶部,在导入之后,输入:
然后转到https://discord.com/developers/applications/上的 bot 控制面板并转到Bot部分。
在那里,在MESSAGE CONTENT INTENT类别中查找参数将需要您的机器人接收大多数消息中的消息内容并选中该框。
一切都会奏效。
将 discord.py 模块迁移到 API v10 后,出现了这个问题。
如果您在一段时间后阅读此内容,则在做出此决定后,它可能不再起作用。Discord 将在两天内关闭对机器人的大部分功能的访问,并在服务器上读取未经验证的机器人的消息内容。验证是在手动模式下进行的,适用于有用、无害且很酷的机器人。