ANTICHAT

ANTICHAT (https://forum.antichat.xyz/index.php)
-   Общие вопросы программирования (https://forum.antichat.xyz/forumdisplay.php?f=206)
-   -   Бот Дискорд (https://forum.antichat.xyz/showthread.php?t=1459984)

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/attachmen...f09693101a.png

laiser 03.12.2022 00:38

Как писал ранее, ДС не знаю. Но в новых версиях ДС, требуется 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/attachmen...26ab1686cf.png

https://forum.antichat.xyz/attachmen...4f388cad9b.png

шайни 03.12.2022 00:53

вместо intents = discord.Intents.default() попробуй intents = discord.Intents.all()

и лишний client тоже убери

laiser 03.12.2022 01:02

Код:





Код:

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/attachmen...701519e468.png

https://forum.antichat.xyz/attachmen...7fc8957235.png

https://forum.antichat.xyz/attachmen...efb7635ea2.png

шайни 03.12.2022 01:08

bot = commands.Bot(command_prefix=config['prefix'], intents=intents)

Grafika1 03.12.2022 01:10

https://forum.antichat.xyz/attachmen...37c9d26289.png

шайни 03.12.2022 01:11

над этой строкой поставь intents = discord.Intents.all()

Grafika1 03.12.2022 01:19

https://forum.antichat.xyz/attachmen...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\Pyth on311\Lib\site-packages\discord\client.py", line 828, in run

asyncio.run(runner())

File "C:\Users\cawa1\AppData\Local\Programs\Python\Pyth on311\Lib\asyncio\runners.py", line 190, in run

return runner.run(main)

^^^^^^^^^^^^^^^^

File "C:\Users\cawa1\AppData\Local\Programs\Python\Pyth on311\Lib\asyncio\runners.py", line 118, in run

return self._loop.run_until_complete(task)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\cawa1\AppData\Local\Programs\Python\Pyth on311\Lib\asyncio\base_events.py", line 650, in run_until_complete

return future.result()

^^^^^^^^^^^^^^^

File "C:\Users\cawa1\AppData\Local\Programs\Python\Pyth on311\Lib\site-packages\discord\client.py", line 817, in runner

await self.start(token, reconnect=reconnect)

File "C:\Users\cawa1\AppData\Local\Programs\Python\Pyth on311\Lib\site-packages\discord\client.py", line 746, in start

await self.connect(reconnect=reconnect)

File "C:\Users\cawa1\AppData\Local\Programs\Python\Pyth on311\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



Время: 03:39