King
King
DIAdiscord.js - Imagine an app
Created by King on 5/12/2024 in #djs-questions
help
const fetch = require('node-fetch'); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\georg\Desktop\brickbronze\looker\node_modules\node-fetch\src\index.js from C:\Users\georg\Desktop\brickbronze\looker\main.js not supported. Instead change the require of index.js in C:\Users\georg\Desktop\brickbronze\looker\main.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (C:\Users\georg\Desktop\brickbronze\looker\main.js:2:15) { code: 'ERR_REQUIRE_ESM' }
10 replies
DIAdiscord.js - Imagine an app
Created by King on 5/11/2024 in #djs-questions
why cant i see my slash command when i test it? its not working
const { Client, Intents } = require('discord.js');

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_VOICE_STATES
]
});

client.once('ready', () => {
console.log('Looker initialised');
});

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;

const { commandName } = interaction;

if (commandName === 'createvoice') {
await createVoiceChannel(interaction);
}
});

async function createVoiceChannel(interaction) {
const guild = interaction.guild;
const membersCount = guild.memberCount;

try {
const channel = await guild.channels.create(`MEMBERS: ${membersCount}`, {
type: 'GUILD_VOICE',
parent: 'YOUR_PARENT_CATEGORY_ID',
permissionOverwrites: [
{
id: guild.roles.everyone,
deny: ['CONNECT']
},
]
});

await interaction.reply(`Voice channel created: ${channel.name}`);
} catch (error) {
console.error('Error creating voice channel:', error);
await interaction.reply('Failed to create voice channel.');
}
}
const { Client, Intents } = require('discord.js');

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_VOICE_STATES
]
});

client.once('ready', () => {
console.log('Looker initialised');
});

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;

const { commandName } = interaction;

if (commandName === 'createvoice') {
await createVoiceChannel(interaction);
}
});

async function createVoiceChannel(interaction) {
const guild = interaction.guild;
const membersCount = guild.memberCount;

try {
const channel = await guild.channels.create(`MEMBERS: ${membersCount}`, {
type: 'GUILD_VOICE',
parent: 'YOUR_PARENT_CATEGORY_ID',
permissionOverwrites: [
{
id: guild.roles.everyone,
deny: ['CONNECT']
},
]
});

await interaction.reply(`Voice channel created: ${channel.name}`);
} catch (error) {
console.error('Error creating voice channel:', error);
await interaction.reply('Failed to create voice channel.');
}
}
15 replies
DIAdiscord.js - Imagine an app
Created by King on 5/11/2024 in #djs-questions
TypeError: Cannot read properties of undefined (reading 'GUILD_VOICE_STATES')
why is this happening const { Client, GatewayIntentBits } = require('discord.js') const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.FLAGS.GUILD_VOICE_STATES ] })
8 replies