johnnymcmike / Gravital

A Discord AI Chatbot that uses GPT-2 and aitextgen for fast, believable responses that you can train on your own discord server's message history
MIT License
34 stars 5 forks source link

Discord now requires Intents for bots #13

Closed Bob-Harper closed 1 year ago

Bob-Harper commented 2 years ago

I could not get the bot to work as written, as discord now apparently requires intents.

I was able to get them working with the following additions:

import discord from discord.ext import commands

right after imports: intents = discord.Intents.all() intents.message_content = True bot = commands.Bot(command_prefix='.', intents=intents, help_command=None)

With "all" enabled we might not need to the message content=true, but I don't feel like with fighting with it more at the moment.

In addition to the above we also need to be sure "bot" is consistent throughout, not so much an issue in this code as is but if adding new events, use bot, not client.

finally, the biggest headache of them all, for me: def init(self, maxlines) -> None: super().init(maxlines=maxlines, intents=intents) self.maxlines = maxlines

Once intents are added, without maxlines=maxlines, intents=intents in the super init, there are all sorts of odd errors, and if you try fixing them one at a time you eventually loop and continue following the error trail. I'd like that week of my life back.

I think those were all the changes i made regarding intents.
Of course this all assumes you also remember to set them up on your bot developer portal page.

Luamnoxu commented 1 year ago

Having issues with this aswell, However Im not experienced at python. Do you mind sharing an updated version of the script?

johnnymcmike commented 1 year ago

hey, sorry for inactivity - there is a PR open to fix this issue, and once i verify what i have to change about the setup process / docs i'm gonna merge it soon and the issue should be fixed. whenever i run the bot i use my old setup i did before this intents change, which still works, so you could probably workaround this temporarily by installing an older version of discord.py