So, I made a discord bot and when I type ?s mute @user
they mute the user by adding Muted
role but when the muted user leaves the Muted
role get's removed so what should I do. Thank you
Also
When I user is muted and leaves the server, there's an Unknown Member error
CodePudding user response:
In this case you should use a database. MongoDb is a good choice for this purpose. But there are also many others that are easy to install and use. Just have a look around on the internet. At least for MongoDb there are many tutorials how to implement it into your Discord bot (It's not really complicated).
Once you have that, every time you mute someone for example, you have to store that role assignment in the database. Query if a new user was already on the server and had the muted role, you should do that for every new member. You should do this query in the event "guildMemberAdd". In the event "guildMemberRemove" (or directly when assigning the role) you can then save important role assignments.
It sounds like a lot of work, but once you figure out how to use the database of your choice, it's a quick fix.