-2

I keep getting this error and can't figure out what will fix it. I use Replit to host my Discord bot, so it should automatically update to the latest discord.py library. I also tried to check guilds on in the URL generator in the developer portal, but it asked me for a redirect URI and would error whenever I tried to provide it. I've tried everything at this point to get this to work, so how do I do this?

Original Question:

'NoneType' object has no attribute 'add_roles'

import os
import discord
from keep_alive import keep_alive
from discord.ext import commands, tasks
import logging
import time
from datetime import datetime
import pytz

intents = discord.Intents.default()
intents.members = True

# When IP abuse occurs, type "kill 1" in the Shell tab.

logging.basicConfig(
  format="%(asctime)s - %(name)s - %(message)s",
  level=logging.INFO,
)
client = commands.Bot(command_prefix="!!", intents=intents)

@client.event
async def on_ready():
  print("I'm in")
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yozy Opto
  • 23
  • 5

1 Answers1

0

Looking at your comment, the reason is discord.Intents only exist on versions 1.5 and higher. So this package does not get updated properly. Go in the Replit terminal, and type pip3 install discord.py --upgrade, and make sure it installs the newest version of the library.

You will also need to enable intents in the Discord developer portal. Go to your application, and under the Bot section enable the privileged gateway intents that you will need (based on your code above, it looks like you will require the Server Members Intent).

Privileged Gateway Intents

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
TheOneMusic
  • 1,776
  • 3
  • 15
  • 39
  • Where's the replit terminal? I tried inserting that into the console and it errored – Yozy Opto Apr 13 '23 at 20:50
  • ```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.``` How do I do this? I went to the page and can't find intents – Yozy Opto Apr 15 '23 at 03:11
  • When I typed that in, it updated but now the bot seems to REQUIRE intents and won't work at all now – Yozy Opto Apr 15 '23 at 03:15
  • For some reason it's showing 'discord' has no attribute 'Intents' again. I updated it and now when I try to update it says ```no such option: --update``` – Yozy Opto Apr 15 '23 at 04:27
  • Ohhhhhh whoops. – Yozy Opto Apr 15 '23 at 04:32
  • It said ```Successfully installed aiohttp-3.8.4 async-timeout-4.0.2 discord.py-2.2.2``` but the version is still 1.3.4 – Yozy Opto Apr 15 '23 at 04:37
  • No not yet sadly – Yozy Opto Apr 24 '23 at 13:54