theold.kingu
theold.kingu
DIAdiscord.js - Imagine a boo! 👻
Created by theold.kingu on 5/10/2024 in #djs-questions
const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD
how do i make a client with the same intent flags in v14
7 replies
DIAdiscord.js - Imagine a boo! 👻
Created by theold.kingu on 5/6/2024 in #djs-questions
i have a doubt is the intent fuction update in v14.5.0 ?
const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] });
18 replies
DIAdiscord.js - Imagine a boo! 👻
Created by theold.kingu on 11/16/2023 in #djs-questions
my bot is unable to read messages

const { Client, GatewayIntentBits, Intents } = require('discord.js');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, NoSubscriberBehavior } = require('@discordjs/voice');
const { createWriteStream } = require('fs');
const prism = require('prism-media');
const { pipeline } = require('stream');

// Define the bot client
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_VOICE_STATES, // Use GUILD_VOICE_STATES instead of GuildVoiceStates
],
});


// Define a collection to store voice connections
client.voiceConnections = new Map();

// Event: When the bot is ready
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});

// Event: When a message is received
client.on('messageCreate', async (message) => {
console.log(`message`)
// Check if the message author is a bot
if (message.author.bot) return;

// Check if the message starts with the command !record
if (message.content=='!record') {
// Check if the author is in a voice channel
const voiceChannel = message.member?.voice.channel;
if (!voiceChannel) {
return message.reply('You must be in a voice channel to use this command!');
}

// Check if the bot is already in a voice connection in the guild
if (client.voiceConnections.has(message.guild.id)) {
return message.reply('I am already recording in a voice channel!');
}


client.login(process.env.TOKEN);

const { Client, GatewayIntentBits, Intents } = require('discord.js');
const { joinVoiceChannel, createAudioResource, createAudioPlayer, NoSubscriberBehavior } = require('@discordjs/voice');
const { createWriteStream } = require('fs');
const prism = require('prism-media');
const { pipeline } = require('stream');

// Define the bot client
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_VOICE_STATES, // Use GUILD_VOICE_STATES instead of GuildVoiceStates
],
});


// Define a collection to store voice connections
client.voiceConnections = new Map();

// Event: When the bot is ready
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});

// Event: When a message is received
client.on('messageCreate', async (message) => {
console.log(`message`)
// Check if the message author is a bot
if (message.author.bot) return;

// Check if the message starts with the command !record
if (message.content=='!record') {
// Check if the author is in a voice channel
const voiceChannel = message.member?.voice.channel;
if (!voiceChannel) {
return message.reply('You must be in a voice channel to use this command!');
}

// Check if the bot is already in a voice connection in the guild
if (client.voiceConnections.has(message.guild.id)) {
return message.reply('I am already recording in a voice channel!');
}


client.login(process.env.TOKEN);
26 replies