My bot stop Giving Roles and Removing them after a while

await GiveRole(guildid,user,role)

async GiveRole(GuildID, PlayerID, RoleID) {
const Guild = await this.luna.guilds.cache.get(GuildID);
if(Guild){


const Member = await Guild.members.cache.find(member => member.id == PlayerID)
if (!Member) return console.log(`[ERROR GiveRole][@Function] #i can't find the @Member with (ID = ${PlayerID}) in @Guild (ID = ${GuildID})`);
const Role = await Guild.roles.cache.find(role => role.id == RoleID)
if (!Role) return console.log(`[ERROR GiveRole][@Function] #i can't find the @Role with (ID = ${RoleID}) in @Guild (ID = ${GuildID})`);

await Member.roles.add(Role).catch(error => {
console.error(`[ERROR GiveRole][@Function] #i can't Add the @Role with (ID = ${RoleID}) to @Member with (ID = ${PlayerID}) in @Guild (ID = ${GuildID})`)
});
}
}
await GiveRole(guildid,user,role)

async GiveRole(GuildID, PlayerID, RoleID) {
const Guild = await this.luna.guilds.cache.get(GuildID);
if(Guild){


const Member = await Guild.members.cache.find(member => member.id == PlayerID)
if (!Member) return console.log(`[ERROR GiveRole][@Function] #i can't find the @Member with (ID = ${PlayerID}) in @Guild (ID = ${GuildID})`);
const Role = await Guild.roles.cache.find(role => role.id == RoleID)
if (!Role) return console.log(`[ERROR GiveRole][@Function] #i can't find the @Role with (ID = ${RoleID}) in @Guild (ID = ${GuildID})`);

await Member.roles.add(Role).catch(error => {
console.error(`[ERROR GiveRole][@Function] #i can't Add the @Role with (ID = ${RoleID}) to @Member with (ID = ${PlayerID}) in @Guild (ID = ${GuildID})`)
});
}
}
my bot working fine at the first but after a wile it stop adding and removing roles some member here help me and they tall me it's because a async/await problem but i don't think soo because i using pm2 to restart my project after 1hour so it's imposable to be a cash or something on my code not making it work i think maybe because the rate limiting but i want to ask first
3 Replies
d.js toolkit
d.js toolkitā€¢10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Radis Easton
Radis EastonOPā€¢10mo ago
thank you all most every 1 hour and remove from alot of members šŸ„² i have a system that makes members join a room using reaction then after one hour remove them all like an event oh yeah this is will be good thank you
brncray
brncrayā€¢10mo ago
when you re-create the role you're gonna have to set the permissions again just an fyi or wait i mis-read your stuff nevermind me
Want results from more Discord servers?
Add your server