™Z1cool
™Z1cool
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
and I appreciate the help
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
so now this is the new error
Message received: !t
Arguments: [ '!t' ]
Command: !t
Command received:
Attempting to join voice channel: General
Error: TypeError: message.member.voice.channel.join is not a function
Message received: !t
Arguments: [ '!t' ]
Command: !t
Command received:
Attempting to join voice channel: General
Error: TypeError: message.member.voice.channel.join is not a function
heres the code
require("dotenv").config();
const { Client, GatewayIntentBits } = require("discord.js");

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
];

const client = new Client({ intents });

client.on("ready", async () => {
console.log("Bot is ready!");
});

client.on("messageCreate", async (message) => {
console.log("Message received:", message.content);
if (message.content.toLowerCase() === "!t") {
try {
const args = message.content.trim().split(/ +/);
console.log("Arguments:", args);

const command = args.shift().toLowerCase();
console.log("Command:", command);

if (command === "!t") {
const textToSpeak = args.join(" ");
console.log("Command received:", textToSpeak);

if (!message.member || !message.member.voice || !message.member.voice.channel) {
return message.reply("You need to be in a voice channel to use this command.");
}

console.log("Attempting to join voice channel:", message.member.voice.channel.name);
const connection = await message.member.voice.channel.join();
console.log("Joined voice channel:", connection.channel.name);

const dispatcher = connection.play(`http://ttsmp3.com/text-to-speech/${encodeURIComponent(textToSpeak)}`);

dispatcher.on("finish", () => {
console.log("Finished playing TTS. Disconnecting from voice channel.");
connection.disconnect();
});
}
} catch (error) {
console.error("Error:", error);
}
}
});

client.login(process.env.BOT_TOKEN);
require("dotenv").config();
const { Client, GatewayIntentBits } = require("discord.js");

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
];

const client = new Client({ intents });

client.on("ready", async () => {
console.log("Bot is ready!");
});

client.on("messageCreate", async (message) => {
console.log("Message received:", message.content);
if (message.content.toLowerCase() === "!t") {
try {
const args = message.content.trim().split(/ +/);
console.log("Arguments:", args);

const command = args.shift().toLowerCase();
console.log("Command:", command);

if (command === "!t") {
const textToSpeak = args.join(" ");
console.log("Command received:", textToSpeak);

if (!message.member || !message.member.voice || !message.member.voice.channel) {
return message.reply("You need to be in a voice channel to use this command.");
}

console.log("Attempting to join voice channel:", message.member.voice.channel.name);
const connection = await message.member.voice.channel.join();
console.log("Joined voice channel:", connection.channel.name);

const dispatcher = connection.play(`http://ttsmp3.com/text-to-speech/${encodeURIComponent(textToSpeak)}`);

dispatcher.on("finish", () => {
console.log("Finished playing TTS. Disconnecting from voice channel.");
connection.disconnect();
});
}
} catch (error) {
console.error("Error:", error);
}
}
});

client.login(process.env.BOT_TOKEN);
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
okay thanks
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
it just logging Message received: !t test
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
heres the updated code
require("dotenv").config();
const { Client, GatewayIntentBits } = require("discord.js");

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
];

const client = new Client({ intents });

client.on("ready", async () => {
console.log("Bot is ready!");
});

client.on("messageCreate", async (message) => {
console.log("Message received:", message.content);
if (message.content.toLowerCase() === "!t") {
try {
const args = message.content.trim().split(/ +/);
console.log("Arguments:", args);

const command = args.shift().toLowerCase();
console.log("Command:", command);

if (command === "!t") {
const textToSpeak = args.join(" ");
console.log("Command received:", textToSpeak);

if (!message.member.voice.channel) {
return message.reply("You need to be in a voice channel to use this command.");
}

console.log("Attempting to join voice channel:", message.member.voice.channel.name);
const connection = await message.member.voice.channel.join();
console.log("Joined voice channel:", connection.channel.name);

const dispatcher = connection.play(`http://ttsmp3.com/text-to-speech/${encodeURIComponent(textToSpeak)}`);

dispatcher.on("finish", () => {
console.log("Finished playing TTS. Disconnecting from voice channel.");
connection.disconnect();
});
}
} catch (error) {
console.error("Error:", error);
}
}
});

client.login(process.env.BOT_TOKEN);
require("dotenv").config();
const { Client, GatewayIntentBits } = require("discord.js");

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
];

const client = new Client({ intents });

client.on("ready", async () => {
console.log("Bot is ready!");
});

client.on("messageCreate", async (message) => {
console.log("Message received:", message.content);
if (message.content.toLowerCase() === "!t") {
try {
const args = message.content.trim().split(/ +/);
console.log("Arguments:", args);

const command = args.shift().toLowerCase();
console.log("Command:", command);

if (command === "!t") {
const textToSpeak = args.join(" ");
console.log("Command received:", textToSpeak);

if (!message.member.voice.channel) {
return message.reply("You need to be in a voice channel to use this command.");
}

console.log("Attempting to join voice channel:", message.member.voice.channel.name);
const connection = await message.member.voice.channel.join();
console.log("Joined voice channel:", connection.channel.name);

const dispatcher = connection.play(`http://ttsmp3.com/text-to-speech/${encodeURIComponent(textToSpeak)}`);

dispatcher.on("finish", () => {
console.log("Finished playing TTS. Disconnecting from voice channel.");
connection.disconnect();
});
}
} catch (error) {
console.error("Error:", error);
}
}
});

client.login(process.env.BOT_TOKEN);
but still isn't joining vc though when I use the command
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
oh lol
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
require("dotenv").config();
const { Client, GatewayIntentBits } = require("discord.js");

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
];

const client = new Client({ intents });

client.on("ready", async () => {
console.log("Bot is ready!");
});

client.on("messageCreate", async (message) => {
console.log("Message received:", message.content);
if (message.content.toLowerCase() === "!t") {
try {
const args = message.content.trim().split(/ +/);
console.log("Arguments:", args);

const command = args.shift().toLowerCase();
console.log("Command:", command);

if (command === "!t") {
const textToSpeak = args.join(" ");
console.log("Command received:", textToSpeak);

if (!message.member.voice.channel) {
return message.reply("You need to be in a voice channel to use this command.");
}

console.log("Attempting to join voice channel:", message.member.voice.channel.name);
const connection = await message.member.voice.channel.join();
console.log("Joined voice channel:", connection.channel.name);

const dispatcher = connection.play(`http://ttsmp3.com/text-to-speech/${encodeURIComponent(textToSpeak)}`);

dispatcher.on("finish", () => {
console.log("Finished playing TTS. Disconnecting from voice channel.");
connection.disconnect();
});
}
} catch (error) {
console.error("Error:", error);
}
}
});

client.login(process.env.BOT_TOKEN);
require("dotenv").config();
const { Client, GatewayIntentBits } = require("discord.js");

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
];

const client = new Client({ intents });

client.on("ready", async () => {
console.log("Bot is ready!");
});

client.on("messageCreate", async (message) => {
console.log("Message received:", message.content);
if (message.content.toLowerCase() === "!t") {
try {
const args = message.content.trim().split(/ +/);
console.log("Arguments:", args);

const command = args.shift().toLowerCase();
console.log("Command:", command);

if (command === "!t") {
const textToSpeak = args.join(" ");
console.log("Command received:", textToSpeak);

if (!message.member.voice.channel) {
return message.reply("You need to be in a voice channel to use this command.");
}

console.log("Attempting to join voice channel:", message.member.voice.channel.name);
const connection = await message.member.voice.channel.join();
console.log("Joined voice channel:", connection.channel.name);

const dispatcher = connection.play(`http://ttsmp3.com/text-to-speech/${encodeURIComponent(textToSpeak)}`);

dispatcher.on("finish", () => {
console.log("Finished playing TTS. Disconnecting from voice channel.");
connection.disconnect();
});
}
} catch (error) {
console.error("Error:", error);
}
}
});

client.login(process.env.BOT_TOKEN);
when I try adding the
MessageContent
MessageContent
kept on getting an error so I will add that later on
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
So the message is getting recived but not joining vc nor telling me that I have to be in a vc
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
oh okay thanks
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
instead of message.content?
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
Thanks Ill fix the other line
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
so like this? client.on("messageCreate", async (message) => {
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
oh okay thanks
38 replies
DIAdiscord.js - Imagine an app
Created by ™Z1cool on 1/3/2024 in #djs-questions
Discord TTS bot
is this line of code? client.on("message", async (message) => {
38 replies