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 (duplicate, somehow submitted in error) #14

Closed Bob-Harper closed 2 years 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.