Ian
Ian
DIAdiscord.js - Imagine an app
Created by Ian on 9/3/2024 in #djs-questions
Getting rate-limited for making a role
I'm currently working on a bot that makes around 4 - 5 roles to play a round of Mafia. Unfortunately, I'm unable to implement my channels / roles - whenever I attempt to make one role, I get a rate limit message in my terminal, let alone make multiple. I'm not sure what it could be, as only one file is actually concerned with making roles and referencing them and I'm only doing it once. I've tried waiting a few minutes to a few hours to relaunch my bot and I'm still having no luck. After waiting, sometimes one role will be made, sometimes two, sometimes everything will work and sometimes nothing will work. It's a bit frustrating. Is it possible that I have a lot of requests in some theoretical queue? Or is it something with my codebase? Relevant snippets below: start.ts
module.exports = {
data: new SlashCommandBuilder()
.setName("start")
.setDescription("Creates a new town."),

async execute(interaction) {
// Doesn't have anything to do with the Game class after inspection.
const guild: Guild = interaction.guild;

if (Game.townBuilder == null) {
// Commented out code for testing.

const alive = await guild.roles.create({
name: "Alive",
color: Number(0x98A6D9),
hoist: true,
position: 10,
mentionable: false,
permissions: [
PermissionsBitField.Flags.Connect,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.Speak,
PermissionsBitField.Flags.ViewChannel
]
}); // This role is not being made.
module.exports = {
data: new SlashCommandBuilder()
.setName("start")
.setDescription("Creates a new town."),

async execute(interaction) {
// Doesn't have anything to do with the Game class after inspection.
const guild: Guild = interaction.guild;

if (Game.townBuilder == null) {
// Commented out code for testing.

const alive = await guild.roles.create({
name: "Alive",
color: Number(0x98A6D9),
hoist: true,
position: 10,
mentionable: false,
permissions: [
PermissionsBitField.Flags.Connect,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.Speak,
PermissionsBitField.Flags.ViewChannel
]
}); // This role is not being made.
terminal output
{
global: false,
method: 'POST',
url: 'https://discord.com/api/v10/guilds/--guildId--/roles',
route: '/guilds/:id/roles',
majorParameter: '--param--',
hash: 'Global(POST:/guilds/:id/roles)',
limit: 250, // Role rate limit despite doing it one time ... ?
timeToReset: 172345747,
retryAfter: 172345747,
sublimitTimeout: 0,
scope: 'user'
} <-- Appears right after the slash command is called.
{
global: false,
method: 'POST',
url: 'https://discord.com/api/v10/guilds/--guildId--/roles',
route: '/guilds/:id/roles',
majorParameter: '--param--',
hash: 'Global(POST:/guilds/:id/roles)',
limit: 250, // Role rate limit despite doing it one time ... ?
timeToReset: 172345747,
retryAfter: 172345747,
sublimitTimeout: 0,
scope: 'user'
} <-- Appears right after the slash command is called.
Please let me know if I am missing any relevant information for diagnosing this problem (or if I'm in the wrong server). Thanks! :)
2 replies