Просмотр полной версии : Бот Дискорд
Grafika1
02.12.2022, 23:34
Как исправить это?
bot discord:
import
discord
import
json
from
discord
.
ext
import
commands
file
=
open
(
'config.json'
,
'r'
)
config
=
json
.
load
(
file
)
bot
=
commands
.
Bot
(
command_prefix
=
config
[
'prefix'
]
)
@bot.command
(
name
=
'ping'
)
async
def
ping
(
ctx
)
:
await
ctx
.
send
(
f'{ctx.author.mention}pong'
)
bot
.
run
(
config
[
'token'
]
)
Traceback (most recent call last):
File "C:\Users\cawa1\Desktop\Discord Bot\main.py", line 9, in
bot = commands.Bot(command_prefix=config['prefix'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
https://forum.antichat.xyz/attachments/28207686/img_f09693101a.png
Как писал ранее, ДС не знаю. Но в новых версиях ДС, требуется intents
Попробуй:
Код:
# before
client = discord.Client()
# after
intents = discord.Intents.default()
client = discord.Client(intents=intents)
Источник
Grafika1
03.12.2022, 00:51
https://forum.antichat.xyz/attachments/28207715/img_26ab1686cf.png
https://forum.antichat.xyz/attachments/28207715/img_4f388cad9b.png
вместо intents = discord.Intents.default() попробуй intents = discord.Intents.all()
и лишний client тоже убери
Код:
import discord
import json
from discord.ext import commands
file = open('config.json', 'r')
config = json.load(file)
bot = commands.Bot(command_prefix=config['prefix'])
intents = discord.Intents.default()# или intents = discord.Intents.all()
client = discord.Client(intents=intents)
@bot.command(name='ping')
async def ping(ctx):
await ctx.send(f'{ctx.author.mention}pong')
bot.run(config['token'])
Grafika1
03.12.2022, 01:03
https://forum.antichat.xyz/attachments/28207721/img_701519e468.png
https://forum.antichat.xyz/attachments/28207721/img_7fc8957235.png
https://forum.antichat.xyz/attachments/28207721/img_efb7635ea2.png
bot = commands.Bot(command_prefix=config['prefix'], intents=intents)
Grafika1
03.12.2022, 01:10
https://forum.antichat.xyz/attachments/28207727/img_37c9d26289.png
над этой строкой поставь intents = discord.Intents.all()
Grafika1
03.12.2022, 01:19
https://forum.antichat.xyz/attachments/28207733/img_ca5c2d7c71.png
2022-12-02 23:16:40 INFO discord.client logging in using static token
Traceback (most recent call last):
File "C:\Users\cawa1\Desktop\Discord Bot\main.py", line 19, in
bot.run(config['token'])
File "C:\Users\cawa1\AppData\Local\Programs\Python\Pytho n311\Lib\site-packages\discord\client.py", line 828, in run
asyncio.run(runner())
File "C:\Users\cawa1\AppData\Local\Programs\Python\Pytho n311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\cawa1\AppData\Local\Programs\Python\Pytho n311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cawa1\AppData\Local\Programs\Python\Pytho n311\Lib\asyncio\base_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\cawa1\AppData\Local\Programs\Python\Pytho n311\Lib\site-packages\discord\client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\cawa1\AppData\Local\Programs\Python\Pytho n311\Lib\site-packages\discord\client.py", line 746, in start
await self.connect(reconnect=reconnect)
File "C:\Users\cawa1\AppData\Local\Programs\Python\Pytho n311\Lib\site-packages\discord\client.py", line 672, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Process finished with exit code 1
заходи на https://discord.com/developers/applications/ , далее выбираешь своего бота, после заходишь в Bot и там ставишь как на скрине
Grafika1
03.12.2022, 01:33
Спасибо
vBulletin® v3.8.14, Copyright ©2000-2026, vBulletin Solutions, Inc. Перевод: zCarot