vlad vollar
vlad vollar
DIAdiscord.js - Imagine an app
Created by vlad vollar on 6/12/2024 in #djs-questions
TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
VoiceStateUpdate Event.
for (let userId of trustedUsers) {
let user = newChannel.guild.members.cache.get(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
} else {
try {
user = await newChannel.guild.members.fetch(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
}
} catch (error) {
console.log(`Invalid user ID in trustedUsers: ${userId}`);
}
}
}

const channel = await newChannel?.guild?.channels.create({
name: roomName,
parent: privateRoomsCategoryId,
type: ChannelType.GuildVoice,
userLimit: userLimit,
permissionOverwrites: permissionOverwrites
}).catch((e) => {console.log(e)})
for (let userId of trustedUsers) {
let user = newChannel.guild.members.cache.get(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
} else {
try {
user = await newChannel.guild.members.fetch(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
}
} catch (error) {
console.log(`Invalid user ID in trustedUsers: ${userId}`);
}
}
}

const channel = await newChannel?.guild?.channels.create({
name: roomName,
parent: privateRoomsCategoryId,
type: ChannelType.GuildVoice,
userLimit: userLimit,
permissionOverwrites: permissionOverwrites
}).catch((e) => {console.log(e)})
5 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 11/28/2023 in #djs-questions
Error [ShardingInProcess]: Shards are still being spawned.
No description
5 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 10/6/2023 in #djs-questions
UserSelectMenuBuilder the interaction failed
No description
7 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 9/24/2023 in #djs-questions
ModalSubmitInteractionFieldNotFound
This error appear in ALL modals (after new updates). Why might this error appear? This happens when sending data through a modal window, but not always
const modal = new ModalBuilder()
.setCustomId('modal')
.setTitle(modalTitle);

const idInput = new TextInputBuilder()
.setCustomId('invite_moderation_notification_content_or_embed')
.setLabel(modalInviteModerationNotificationContentOrEmbedLabel)
.setPlaceholder(modalInviteModerationNotificationContentOrEmbedPlaceholder)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true);

const row = new ActionRowBuilder().addComponents(idInput);
modal.addComponents(row);

let submitted;
try {
await i.showModal(modal);
submitted = await i.awaitModalSubmit({time: 0});
await submitted.deferUpdate();
} catch (e) {
return;
}
const invite_moderation_notification_content_or_embed = submitted.fields.getTextInputValue('invite_moderation_notification_content_or_embed')
const modal = new ModalBuilder()
.setCustomId('modal')
.setTitle(modalTitle);

const idInput = new TextInputBuilder()
.setCustomId('invite_moderation_notification_content_or_embed')
.setLabel(modalInviteModerationNotificationContentOrEmbedLabel)
.setPlaceholder(modalInviteModerationNotificationContentOrEmbedPlaceholder)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true);

const row = new ActionRowBuilder().addComponents(idInput);
modal.addComponents(row);

let submitted;
try {
await i.showModal(modal);
submitted = await i.awaitModalSubmit({time: 0});
await submitted.deferUpdate();
} catch (e) {
return;
}
const invite_moderation_notification_content_or_embed = submitted.fields.getTextInputValue('invite_moderation_notification_content_or_embed')
17 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 8/2/2023 in #djs-questions
Problem with AuditLogs (MessageDelete)
I have some problem. If some other person deletes my message, and then I delete my messages, it will write that he deleted my messages. How to fix it?
let deleter = null
const auditLogs = await msg.guild.fetchAuditLogs({
type: 72,
limit: 1,
time: {after: msg.createdTimestamp},
target: msg.id
})
const auditLogEntry = auditLogs.entries.first()
if (
auditLogEntry?.target?.id === msg.author.id &&
auditLogEntry?.extra?.channel?.id === msg.channel.id
) {
deleter = auditLogEntry.executor;
}
let deleter = null
const auditLogs = await msg.guild.fetchAuditLogs({
type: 72,
limit: 1,
time: {after: msg.createdTimestamp},
target: msg.id
})
const auditLogEntry = auditLogs.entries.first()
if (
auditLogEntry?.target?.id === msg.author.id &&
auditLogEntry?.extra?.channel?.id === msg.channel.id
) {
deleter = auditLogEntry.executor;
}
15 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 7/25/2023 in #djs-questions
Set deafen
10 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 7/15/2023 in #djs-questions
Problem with oldMessage
2 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 5/18/2023 in #djs-questions
Slash commands localization
4 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 5/9/2023 in #djs-questions
Problem with GuildMemberUpdate
11 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 4/12/2023 in #djs-questions
guild.preferredLocale
I have a problem. The server owner (I) uses the russian language, but for some reason I get "en-US"
const locale = msg.guild.preferredLocale
console.log(locale)
const locale = msg.guild.preferredLocale
console.log(locale)
4 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 4/7/2023 in #djs-questions
incorrect presence display
14 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 4/7/2023 in #djs-questions
Slash commands are not registered
I cleared commands with [], the commands cleared successfully. I re-register commands, commands that were previously registered appear, but my new file still does not want to register deploy-commands.js:
import { REST, Routes } from 'discord.js'
import * as commandModules from '../commands/index.js'
import { config } from '../config.js'

const commands = []

for (const module of Object.values(commandModules)) {
commands.push(module.data)
}

const rest = new REST({ version: '10' }).setToken(config.DISCORD_TOKEN)

rest
.put(Routes.applicationCommands(config.CLIENT_ID), { body: commands })
.then(() => {
console.log('Successfully registered application commands')
process.exit(0)
})
.catch(console.error)
import { REST, Routes } from 'discord.js'
import * as commandModules from '../commands/index.js'
import { config } from '../config.js'

const commands = []

for (const module of Object.values(commandModules)) {
commands.push(module.data)
}

const rest = new REST({ version: '10' }).setToken(config.DISCORD_TOKEN)

rest
.put(Routes.applicationCommands(config.CLIENT_ID), { body: commands })
.then(() => {
console.log('Successfully registered application commands')
process.exit(0)
})
.catch(console.error)
hello.js:
import {SlashCommandBuilder} from 'discord.js'

export const data = new SlashCommandBuilder()
.setName('hello')
.setDescription('hello.')

export async function execute(interaction, client) {
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`)
}
import {SlashCommandBuilder} from 'discord.js'

export const data = new SlashCommandBuilder()
.setName('hello')
.setDescription('hello.')

export async function execute(interaction, client) {
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`)
}
11 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 2/18/2023 in #djs-questions
GuildMemberUpdate didn't work
What's wrong? Code here: https://pastebin.com/YB4gbmNC
6 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 1/18/2023 in #djs-voice
user presence
How can I get a user presence status with slash commands?
7 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 1/16/2023 in #djs-questions
Buttons respond a certain number of times
8 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 1/10/2023 in #djs-questions
Get emoji
How can I get emoji with interaction? If I use
const someEmoji = client.emojis.get("id");
const someEmoji = client.emojis.get("id");
I get an error ReferenceError: client is not defined
13 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 1/10/2023 in #djs-questions
Avatar format
Why does it give me the format webp?
${user.avatarURL({ format: 'jpg', dynamic: true, size: 2048 })}
${user.avatarURL({ format: 'jpg', dynamic: true, size: 2048 })}
4 replies
DIAdiscord.js - Imagine an app
Created by vlad vollar on 1/9/2023 in #djs-questions
Slash command not registered
I use code from discord js guide, but command not registered. Code: https://pastebin.com/MLS0AxEB
42 replies