Closed EclipseGame18 closed 1 year ago
Hello ! Can you send the complete error?
Sure:
C:\Users\Desktop\T.B.T.D.A 2.0 Web Dashboard\node_modules\discord-easy-dashboard\routes\manage.js:11
if (!member || !member.permissions.has(req.dashboardConfig.permissions)) return res.redirect('/selector');
^
TypeError: Cannot read properties of undefined (reading 'has')
at C:\Users\Desktop\T.B.T.D.A 2.0 Web Dashboard\node_modules\discord-easy-dashboard\routes\manage.js:11:38
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v19.9.0
perhaps member.permissions.has(MANAGE_GUILD)
was changed in the newer versions of discord.js?
from the docs, the new syntax is:
member.permissions.has(PermissionsBitField.Flags.ManageGuild)
(just a speculation)
The problem seems to be that member.permissions is set to undefined for some unknown reason. I would have to debug the module but I don't have much time right now. I might do it one day, in the meantime if you find a solution don't hesitate to open a pull request!
PS: duplicate of https://github.com/SimonLeclere/discord-easy-dashboard/issues/29
I have found the problem:
req.user.id
turns up undefined
when just using guild.members.fetch()
i can get all members and info, when trying to filter with req.user.id
it throws an error because there are no results to get permissions value form. I hope this will help with debugging! (when you get time)
Hey, which version of discord.js are you using ?
The latest, but I also tried cloning the discord.js and module version from dash bot
Hey, can you test your code with the latest version published on github to check if your problem has been solved? Normally it should work with the latest version of Discord.js
I tried it but I don't see any serves. nothing else is broken tho
Try setting "ManageGuild" as the permission required
The syntax is no longer MANAGE_GUILD but ManageGuild
it works now, but with const setToggle = async(guild, value)
guild seems to be null and value is the guild id
I'll check that
thx
would you like to see my code for that?
Yes that could help thanks!
const setToggle = async(guild, value) => {
await ToggleAntiSware.findOneAndUpdate({
_id: guild.id
},{
_id: guild.id,
toggle: value,
},{
upsert: true
})
}
const getToggle = async(guild) => {
const toggleSware = await ToggleAntiSware.findOne({_id: guild.id}).catch(error =>{
console.log(`There was a error: ${error}`)
})
if (toggleSware.toggle == true){
return true;
} else{
return false;
}}
client.dashboard.addBooleanInput('Toggle sware detection', "enter either 'on' or 'off' to toggle the anti-swear function.", setToggle, getToggle);
(i use mongoDB for storage)
Hey, the module works fine as it should. However, the set and get functions also take the client as a parameter.
const setter = (discordClient, guild, value) => { ... };
const getter = (discordClient, guild) => { ... };
Also here is a better version of your getter function :
const getToggle = async (discordClient, guild) => {
const toggleSware = await ToggleAntiSware.findOne({ _id: guild.id }).catch(error =>{
console.log(`There was a error: ${error}`);
});
return toggleSware.toggle || false;
};
thx!
Did it work?
yes
everything works as expected
Perfect !
when I try to go into a guild to change settings, I get this error:
how do I resolve this?