Radis Easton
Radis Easton
DIAdiscord.js - Imagine an app
Created by Radis Easton on 3/18/2024 in #djs-questions
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
10 replies
DIAdiscord.js - Imagine an app
Created by Radis Easton on 3/10/2024 in #djs-questions
remove and add roles stop after time of running ?
hi guy's i want to ask about this problem My bot works on my server to organize the server in general, remove roles, give them and take them away, and arrange the levels within my server. But in the past period The system has become unresponsive to many commands Such as add and remove roles (especially in this regard) As it caused many problems within my server My code works normally when tested on my test bot But when activated in the main bot, the system stops to respone for this handles (give and remove roles) after a while I use a library discord.js Is the problem with the library or is there another defect?
12 replies