wisienka
wisienka
DIAdiscord.js - Imagine an app
Created by wisienka on 9/11/2024 in #djs-questions
Discord permissions
which permission members need to use button on embed message in forum type text channel?
2 replies
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/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