Бот Дискорд

Grafika1

Участник
Автор темы
39
7
Как исправить это?
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 <module>
bot = commands.Bot(command_prefix=config['prefix'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
1670009649760.png
 

laiser

Известный
184
90
Код:
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

Участник
Автор темы
39
7
1670015926605.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 <module>
bot.run(config['token'])
File "C:\Users\cawa1\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 828, in run
asyncio.run(runner())
File "C:\Users\cawa1\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\cawa1\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\cawa1\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\cawa1\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\cawa1\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 746, in start
await self.connect(reconnect=reconnect)
File "C:\Users\cawa1\AppData\Local\Programs\Python\Python311\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