wisienka
wisienka
DIAdiscord.js - Imagine an app
Created by wisienka on 6/3/2024 in #djs-questions
RangeError [MessageNonceType]: Message nonce must be an integer or a string.
hi someone can help me?
require('dotenv').config();
const { EmbedBuilder, AttachmentBuilder, SnowflakeUtil } = require('discord.js');

module.exports = (member) => {
const attachment = new AttachmentBuilder('images/welcome.png', { name: 'welcome.png' });
const embed = new EmbedBuilder()
.setColor(0x169C9C)
.setDescription(`Welcome<@${member.user.id}>! (${member.user.username})\nSome text!\nSome text.\nSome text:\n<#${process.env.RULES_CHANNEL}>\n<#${process.env.TICKETS_CHANNEL}>`)
.setThumbnail(`https://cdn.discordapp.com/avatars/${member.user.id}/${member.user.avatar}.png`)
.setImage('attachment://welcome.png');

const nonce = SnowflakeUtil.generate();
const channel = member.guild.channels.cache.get(process.env.WELCOME_CHANNEL);
channel.send({ embeds: [embed], files: [attachment], enforceNonce: true, nonce: nonce });
};
require('dotenv').config();
const { EmbedBuilder, AttachmentBuilder, SnowflakeUtil } = require('discord.js');

module.exports = (member) => {
const attachment = new AttachmentBuilder('images/welcome.png', { name: 'welcome.png' });
const embed = new EmbedBuilder()
.setColor(0x169C9C)
.setDescription(`Welcome<@${member.user.id}>! (${member.user.username})\nSome text!\nSome text.\nSome text:\n<#${process.env.RULES_CHANNEL}>\n<#${process.env.TICKETS_CHANNEL}>`)
.setThumbnail(`https://cdn.discordapp.com/avatars/${member.user.id}/${member.user.avatar}.png`)
.setImage('attachment://welcome.png');

const nonce = SnowflakeUtil.generate();
const channel = member.guild.channels.cache.get(process.env.WELCOME_CHANNEL);
channel.send({ embeds: [embed], files: [attachment], enforceNonce: true, nonce: nonce });
};
and i've this problem
/home/bot2/node_modules/discord.js/src/structures/MessagePayload.js:132
throw new DiscordjsRangeError(ErrorCodes.MessageNonceType);
^

RangeError [MessageNonceType]: Message nonce must be an integer or a string.
}
/home/bot2/node_modules/discord.js/src/structures/MessagePayload.js:132
throw new DiscordjsRangeError(ErrorCodes.MessageNonceType);
^

RangeError [MessageNonceType]: Message nonce must be an integer or a string.
}
2 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 5/26/2024 in #djs-questions
Bot responding with 2 or 3 messages instead of 1 after being not used for a while
hi, anyone can help me? i have an guildMemberAdd event to welcome my new members on server which sends embed message to specific channel. bot after being not used for around 2 hours and then event got fired, bot send embed message 2 or even 3 times, debugging in code indicates that event got fired 1 time. where can be problem? my bot is for sure opened in one window
10 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 12/15/2023 in #djs-questions
event sometimes got fired 2/3 or event 4 fired
hi i want to ask about events, sometimes my guildmemberadd event got fired 2/3 times and embed message with welcome new user spam welcome channel, what can i do? thats how my event looks
const {
EmbedBuilder, AttachmentBuilder
} = require("discord.js");

require("dotenv").config();

module.exports = {
name: "guildMemberAdd",
async execute(client, member) {
console.log(member);
const channel = client.channels.cache.get(process.env.WELCOME_CHANNEL);

const attachment = new AttachmentBuilder('images/welcome.png', { name: 'welcome.png' });
const embed = new EmbedBuilder()
.setColor(0x169C9C)
.setImage('attachment://welcome.png')
.setDescription(`Witaj <@${member.user.id}>! (${member.user.username})\n
welcome message`)
.setThumbnail(`https://cdn.discordapp.com/avatars/${member.user.id}/${member.user.avatar}.png`);

channel.send({ embeds: [embed], files: [attachment] });
}
}
const {
EmbedBuilder, AttachmentBuilder
} = require("discord.js");

require("dotenv").config();

module.exports = {
name: "guildMemberAdd",
async execute(client, member) {
console.log(member);
const channel = client.channels.cache.get(process.env.WELCOME_CHANNEL);

const attachment = new AttachmentBuilder('images/welcome.png', { name: 'welcome.png' });
const embed = new EmbedBuilder()
.setColor(0x169C9C)
.setImage('attachment://welcome.png')
.setDescription(`Witaj <@${member.user.id}>! (${member.user.username})\n
welcome message`)
.setThumbnail(`https://cdn.discordapp.com/avatars/${member.user.id}/${member.user.avatar}.png`);

channel.send({ embeds: [embed], files: [attachment] });
}
}
33 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 5/18/2023 in #djs-questions
cannot send private message
error code
/root/discord/node_modules/@discordjs/rest/dist/index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50007]: Cannot send messages to this user
at handleErrors (/root/discord/node_modules/@discordjs/rest/dist/index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:1021:23)
at async SequentialHandler.queueRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/root/discord/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async UserManager.createDM (/root/discord/node_modules/discord.js/src/managers/UserManager.js:60:18)
at async GuildMember.send (/root/discord/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:149:18) {
requestBody: { files: undefined, json: { recipient_id: '934834307258802176' } },
rawError: { message: 'Cannot send messages to this user', code: 50007 },
code: 50007,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/users/@me/channels'
}

Node.js v19.2.0
/root/discord/node_modules/@discordjs/rest/dist/index.js:640
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50007]: Cannot send messages to this user
at handleErrors (/root/discord/node_modules/@discordjs/rest/dist/index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:1021:23)
at async SequentialHandler.queueRequest (/root/discord/node_modules/@discordjs/rest/dist/index.js:862:14)
at async REST.request (/root/discord/node_modules/@discordjs/rest/dist/index.js:1387:22)
at async UserManager.createDM (/root/discord/node_modules/discord.js/src/managers/UserManager.js:60:18)
at async GuildMember.send (/root/discord/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:149:18) {
requestBody: { files: undefined, json: { recipient_id: '934834307258802176' } },
rawError: { message: 'Cannot send messages to this user', code: 50007 },
code: 50007,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/users/@me/channels'
}

Node.js v19.2.0
my code looks like
const channel = interaction.channel;
channel.members.forEach(member => {
try {
member.send({ embeds: [embed], components: [row] });
} catch (err) {
console.log(`Problem podczas wysyłania wiadomości do ${member.displayName}`);
console.log(err);
}
});
const channel = interaction.channel;
channel.members.forEach(member => {
try {
member.send({ embeds: [embed], components: [row] });
} catch (err) {
console.log(`Problem podczas wysyłania wiadomości do ${member.displayName}`);
console.log(err);
}
});
i tried everything but anything isn't work
13 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 5/17/2023 in #djs-questions
handle newline in string for build embed
11 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 5/9/2023 in #djs-questions
Fetch more than 100 messages from channel
Hello, it is possible to fetch than more 100 messages from channel?
21 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 5/9/2023 in #djs-questions
how to reset selection on menu after passed interaction
hello i dont have any idea how to reset menu after selection specific value, after execute interaction event i want to change selection to placeholder it is possible?
5 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 5/8/2023 in #djs-questions
create channel doesn't return channel object
hello i want to create an text channel and store it in variable but after debug variable this value is null what i do incorrect?
let guildChannelId = interaction.guild.channels.create({
name: "informacja-" + channelId,
parent: category.id,
type: ChannelType.GuildText,
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
{
id: interaction.user.id,
allow: [PermissionFlagsBits.ViewChannel],
}
]
});
let guildChannelId = interaction.guild.channels.create({
name: "informacja-" + channelId,
parent: category.id,
type: ChannelType.GuildText,
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
{
id: interaction.user.id,
allow: [PermissionFlagsBits.ViewChannel],
}
]
});
2 replies
DIAdiscord.js - Imagine an app
Created by wisienka on 5/6/2023 in #djs-questions
register slash commands doesn't work
hello i used snippet from discordjs.guide for register slash commands, exactly this https://discordjs.guide/creating-your-bot/command-deployment.html#guild-commands and after use node deploy-commands.js nothing shows even console.log included in async function, what i do incorrect?
8 replies