RateLimited
RateLimited
DIAdiscord.js - Imagine an app
Created by RateLimited on 3/14/2025 in #djs-questions
GuildMemberAdd event not working.
const { Events } = require('discord.js');
const fs = require("fs");

module.exports = {
name: Events.GuildMemberAdd,
once: false,
async execute(member,interaction) {
console.log(`${member.user.tag} (${member.user.id})`);
const guildid = member.guild.id ;
const jsonData = JSON.parse(fs.readFileSync(`welcomeConfig/${guildid}-packet.json`, 'utf8'));

const msg = jsonData.msg;
const channel = await interaction.client.channels.fetch(jsonData.channel);

await channel.send(msg);
console.log(msg,channel)

},
};
const { Events } = require('discord.js');
const fs = require("fs");

module.exports = {
name: Events.GuildMemberAdd,
once: false,
async execute(member,interaction) {
console.log(`${member.user.tag} (${member.user.id})`);
const guildid = member.guild.id ;
const jsonData = JSON.parse(fs.readFileSync(`welcomeConfig/${guildid}-packet.json`, 'utf8'));

const msg = jsonData.msg;
const channel = await interaction.client.channels.fetch(jsonData.channel);

await channel.send(msg);
console.log(msg,channel)

},
};
Context i am trying to make a welcome bot, it is grabing msg and the channel from a json file made by the config command
10 replies
DIAdiscord.js - Imagine an app
Created by RateLimited on 3/11/2025 in #djs-questions
Trying to update channel name every min for utc time, updates once but stops updateing
sorry for long title I am trying to make a UTC time channel in my discord server (this is for a game rise of kingdoms which uses utc time), so I made a ClientReady
async execute(client) {
let channel = client.channels.fetch('1348760873849720946');

const getUTC = async () => {
let now = new Date();
let seconds = now.getUTCSeconds();
let delay = (60 - seconds) * 1000; // Calculate delay until the next minute.

setTimeout(async () => {
let updatedNow = new Date();
let hours = updatedNow.getUTCHours().toString().padStart(2, '0'); // Pad single-digit hours with 0.
let minutes = updatedNow.getUTCMinutes().toString().padStart(2, '0'); // Pad single-digit minutes with 0.
console.log("synced");

await channel.setName(`UTC time [ ${hours}:${minutes} ]`);

setInterval(async () => {
let FinNow = new Date();
let FinHours = FinNow.getUTCHours().toString().padStart(2, '0');
let FinMinutes = FinNow.getUTCMinutes().toString().padStart(2, '0');
try {
await channel.setName(`UTC time [ ${FinHours}:${FinMinutes} ]`);
console.log(`Changed `);
} catch(err) {
console.error(err);
}
}, delay);

}, delay);
};

await getUTC();

}
async execute(client) {
let channel = client.channels.fetch('1348760873849720946');

const getUTC = async () => {
let now = new Date();
let seconds = now.getUTCSeconds();
let delay = (60 - seconds) * 1000; // Calculate delay until the next minute.

setTimeout(async () => {
let updatedNow = new Date();
let hours = updatedNow.getUTCHours().toString().padStart(2, '0'); // Pad single-digit hours with 0.
let minutes = updatedNow.getUTCMinutes().toString().padStart(2, '0'); // Pad single-digit minutes with 0.
console.log("synced");

await channel.setName(`UTC time [ ${hours}:${minutes} ]`);

setInterval(async () => {
let FinNow = new Date();
let FinHours = FinNow.getUTCHours().toString().padStart(2, '0');
let FinMinutes = FinNow.getUTCMinutes().toString().padStart(2, '0');
try {
await channel.setName(`UTC time [ ${FinHours}:${FinMinutes} ]`);
console.log(`Changed `);
} catch(err) {
console.error(err);
}
}, delay);

}, delay);
};

await getUTC();

}
Is the issue a discord rate limit? or i am doing something else wrong
7 replies
DIAdiscord.js - Imagine an app
Created by RateLimited on 3/10/2025 in #djs-questions
How do I send a message to a channel by channel id
const channel = interaction.client.channels.fetch('1345305762481569822')
if (interaction.options.getUser('member').bot) {
await channel.send({embeds: [embed1]})
} else {
await channel.send({embeds: [embed1]})
await interaction.options.getUser('member').user.send({embeds: [embed2]})
}
interaction.options.getUser('member').ban({reason:interaction.options.getString('reason')})
const channel = interaction.client.channels.fetch('1345305762481569822')
if (interaction.options.getUser('member').bot) {
await channel.send({embeds: [embed1]})
} else {
await channel.send({embeds: [embed1]})
await interaction.options.getUser('member').user.send({embeds: [embed2]})
}
interaction.options.getUser('member').ban({reason:interaction.options.getString('reason')})
I keep receiving an error as I am trying to send a msg to the channel, Is it a issue with how i am fetching the channel via id.
5 replies
DIAdiscord.js - Imagine an app
Created by RateLimited on 3/8/2025 in #djs-questions
How to use .setChoices/.addChoices. SlashCommandBuilder
context i am making a embed command, i am receiving this error for each of my options
ValidationError: Expected the value to be an object, but received string instead
at _ObjectValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2070:9)
at _ObjectValidator.run (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:958:23)
at _ArrayValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1248:37)
at _ArrayValidator.parse (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at MixedClass.addChoices (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2118:22)
at /Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:10:14
at MixedClass._sharedAddOptionMethod (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2439:50)
at MixedClass.addStringOption (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2411:17)
at Object.<anonymous> (/Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:7:10)
at Module._compile (node:internal/modules/cjs/loader:1739:14) {
validator: 's.object(T)',
given: 'Random'
ValidationError: Expected the value to be an object, but received string instead
at _ObjectValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2070:9)
at _ObjectValidator.run (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:958:23)
at _ArrayValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1248:37)
at _ArrayValidator.parse (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at MixedClass.addChoices (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2118:22)
at /Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:10:14
at MixedClass._sharedAddOptionMethod (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2439:50)
at MixedClass.addStringOption (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2411:17)
at Object.<anonymous> (/Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:7:10)
at Module._compile (node:internal/modules/cjs/loader:1739:14) {
validator: 's.object(T)',
given: 'Random'
note this error is happening with each of my options
4 replies
DIAdiscord.js - Imagine an app
Created by RateLimited on 3/6/2025 in #djs-questions
How to make a new line in app command string option type.
.addStringOption((option) =>
option
.setName('description')
.setDescription('set the description of the embed')

)
.addStringOption((option) =>
option
.setName('description')
.setDescription('set the description of the embed')

)
when inputting the option i am trying to do a new line, it will not let me is there anything i can add to allow this? P.S. I am making a embed command if that helps any
7 replies