\n Line break does not preserve code block text style - discord

\n Does not work as a line break as seen here picture
The section of Code:
client.on("message", message => {
const embedmsg = new discord.MessageEmbed()
.setTitle("About us")
.setDescription("We are team azec we would like to become a big international fortnite team")
.setDescription("`What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches`")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
})

Try setting your text to a variable first
client.on("message", message => {
const desc = "What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches";
const embedmsg = new discord.MessageEmbed()
.setTitle("About us")
.setDescription("We are team azec we would like to become a big international fortnite team")
.setDescription("`" + desc + "`")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
})

Update
I think I get what you mean now. Instead of separated code lines, you want one big code block. Like this:
The trick is instead of using one backtick (`), Discord requires that you use three backticks, like (```) in order to signify that you want to take up multiple lines instead of one. So all you had to do was replace one backtick with three backticks.
Slight changes to osekmedia's observation since your code still pops up errors. I'm also confused by what you mean by \n don't work as line message. Do you mean you want \n to show up in the message itself? If not, then your code is already working fine.
If you ran the code, you would've gotten a MessageEmbed error. To fix that, I would recommend just installing the entire discord.js module.
Code:
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '!';
require('dotenv').config();
client.on("message", message => {
const embedmsg = new Discord.MessageEmbed()
.setTitle("About us")
.setDescription("We are team azec we would like to become a big international fortnite team")
.setDescription("`What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches`")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
});
client.login(process.env.BOTTOKEN);
NEW CODE:
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '!';
require('dotenv').config();
client.on("message", message => {
const embedmsg = new Discord.MessageEmbed()
.setTitle("About us")
.setDescription("```We are team azec we would like to become a big international fortnite team```")
.setDescription("```What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches```")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
});
client.login(process.env.BOTTOKEN);

Related

Why doesn't my welcome message in discord.js work?

i have tried a lot of different ways but this seemed the most used and successful! But it doesn't seem to work for me? I don't need an embed just a simple message. How do i do this correctly?
client.on('guildMemberAdd', async newMember => {
const welcomeChannel = newMember.guild.channels.cache.find(channel => channel.id === 'my channel id is here')
welcomeChannel.send('welcome we hope you have fun')
})
I've tried your code on myself, it is working exactly just as you intended, so I'm assuming that you might not have put the correct intent. Now discord bot need specific intent (depends on what you are trying to do) to work correctly .
And in your case, you are probably missing the "GUILD_MEMBERS" intent. Change it like:
const client = new Client({
intents: 'GUILD_MEMBERS',
})
Also, in case if you are building a local bot and you don't care about intent or you just simply got annoyed by it.
You can also use
const client = new Client({
intents: 32767,
})

Is there an easy way to make my bot mention the person its moving?

so basically I wanted to make my bot move people to afk as soon as they deafen. and I have a command to make it generate messages in chat, but the question is, can I make it # them as well? and if so how?
code:
const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_VOICE_STATES", "GUILD_MEMBERS", "GUILD_PRESENCES"] });
client.on("voiceStateUpdate", (oldState, newState) =>
{
if (newState.selfDeaf)
{
console.log('User has deafened');
newState.member.voice.setChannel("695840093167943751");
client.channels.cache.get("664487959940169738").send('Undeafen Bitch');
}
To tag a user in discord, the format is <#USERID> so if a user's id is 1, you'd have to include <#1> in what you are sending.
So onto your code, you'd have to change the last line to something like the following:
client.channels.cache.get("664487959940169738").send('<#123> Undeafen Bitch');
But we can't hardcode the id since it'll be unique for each user moved. This should automatically tag the user who got moved:
client.channels.cache.get("664487959940169738").send(`<#${newState.member.id}> Undeafen Bitch`);

Discord Missing Intent Error on discord.js

Im having trouble launching my code for the past 6 hours it was working fine yesterday but it doesnt seem to work any more i keep on having an error that says ('CLIENT_MISSING_INTENT')
this is my starting code i dont understand what i am doing wrong
const Discord = require('discord.js'),
welcome = require('./welcome'),
mute = require('./mute'),
unmute = require('./unmute'),
mongoose = require('mongoose'),
Levels = require("discord-xp")
const { Client, Intents } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
You're quite literally missing an Intent. As you're probably already aware based on your code, v13 of discord.js requires you to add certain Intents to avoid processing power being thrown away to features not used.
You can look at all Intents available here, and try to add a few of them to see which one you need. Based on your code I can't see which one you're missing.

My discord.js embed message isnt sending to a specific channel

I don't know what the problem is, here is the code I am using, including the line that is meant to send it to the specified channel:
const Discord = require('discord.js')
const client = new Discord.Client();
const Discord = require('discord.js')
const client = new Discord.Client();
client.on("message", message => {
const embed = new Discord.messageEmbed()
embed.setAuthor(`Phaze Bot`)
embed.setTitle(`Commands List`)
embed.setDescription(`$kick: kicks a member \n $ban: bans a member \n $help music:
displays music commands \n $help: displays the help screen`)
client.guild.channels.cache.get(`801193981115367496`).send(embed)
})
client.login('login in here');
It is not sending this embed to the channel (by ID). Can anyone see where I am wrong?
update
it is now working, but still does not send the code to the channel when i message in it. the Terminal also shows this:
TypeError: Cannot read property 'channels' of undefined
This bot would send an embed every time a user sent a message in any channel.
You also have a typo at your client.on("message", (_message) => {
This needs to be:
client.on("message", message => {
Also, you need the client#channels#cache#get to be:
message.guild.channels.cache.get('801193981115367496').send(embed);
Since the ID is a string, it needs to be held in inverted commas or quotation marks.
As mentioned by Rémy Shyked, quoting the linter from VSCode:
Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers
The ID value is too large to be treated as an integer accurately
As mentioned above, your bot is going to send this embed every time a message is sent. Here is how you would make it respond to a basic help command (without using a handler):
const Discord = require('discord.js')
const client = new Discord.Client();
client.on("message", message => {
if (message.content.toLowerCase() === '!help') {
const embed = new Discord.messageEmbed()
embed.setAuthor(`Phaze Bot`)
embed.setTitle(`Commands List`)
embed.setDescription(`$kick: kicks a member \n $ban: bans a member \n $help music:
displays music commands \n $help: displays the help screen`)
message.guild.channels.cache.get('801193981115367496').send(embed);
};
});
client.login('client login here');
Also, please use semi-colons, and stop using backticks (`) when they aren't necessary - it saves a lot of errors later.

How to create a discord bot that only allows a specific word in a certain text channel

I am trying to create a discord bot that only allows the word "upgrade" in a certain text channel.
As I am very new to this I would like to learn about how this is done.
Its easy. First create a bot. I guess you know about node.js if not, find tutorials for creating a project with discord.js.
First create a client:
const Discord = require("discord.js");
const client = new Discord.Client();
client.login("SuperSecretBotTokenHere");
(make sure you have a bot token) discordapp.com/developers
Then you create a message event:
client.on("message", (message) => {
if(message.content != "upgrade") return message.delete()
});
Put your bot in the server, give it permissions to delete messages in the channel aaand done!
Sorry for my bad English.

Resources