Discord.js embed say command - discord

I am trying to code a command so when someone says !embed it sends an embed to their channel with the title, description and the color as they put in the message, can someone help me?

//the message must be like (!embed Title-<> Color-<> Description)
//!embed Title-<test one> Color-<#ffffff> test test test test test
let title = message.content.split("Title-<")[1].split(">")[0];
let color = message.content.split("Color-<")[1].split(">")[0];
let description = message.content
.replace("!embed","")
.replace(`Title-<${title}>`,"")
.replace(`Color-<${color}>`,"")
let embed = new Discord.MessageEmbed()
.setTitle(title)
.setDescription(description)
.setColor(color)
message.channel.send(embed)
well, I am not good at English
but if the answer is not working , plz tell me to modify it
it will work like this

Related

Discord.js v12 image in message embed

I would like to make a vouch system but with images, when they take screenshot with lightshot to copy the image and paste it to discord chat and when it's been sent, bot will upload it in embed.
My current attempt:
client.on("message", message => {
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (message.channel.id == `912767631344423032`) { //Channel ID
if (message.author.bot) return;
message.delete();
const vch = new Discord.MessageEmbed()
.setTitle(`Feedback`)
.setColor("#F3950D")
.setDescription(`<a:bluefire:911708697988845569> Vouched By:\n**${message.author.tag}**`)
.setThumbnail("https://cdn.discordapp.com/icons/911530458637033514/a_d62f915")
.setImage(`${message.content}`)
.setFooter("Created and Developed by Tana#6969 ❤️")
message.channel.send(vch)
}
});
What does it do now? Like you haven't shown any errors or any parts where we can see the problem is at.
Message.content relates to the message content (text), if no message content (text) is sent it will result into null. You would need to get the image from the attachment option. https://discord.js.org/#/docs/main/v12/class/Message?scrollTo=attachments
There is a lot of ways of doing this, you can go to google and look for a picture that suits you, then right-click it and click "Copy image link" or something similar, or you can do the same but on discord, by sending the image you want then opening it then right-clicking it then choose "Copy image link" or something similar.

Discord.js - How to copy a portion of an other bot's embed

I want to copy some text information displayed on an embed of another bot, and then post that information from my bot. I am completely stuck on how to do this. How would I?
Like this:
client.on('message', message => {
message.embeds.forEach(embed => {
//You can resend the embed whole or some parts of it
//If you want to resend the whole embed
message.channel.send(embed);
//Or, some parts of it
let description = embed.description;
let title = embed.title;
if(title && description){
let emb = new Discord.MessageEmbed()
.setTitle(title)
.setDescription(description)
message.channel.send(emb);
}
});
});
Also check this out Read contents of an embed message from a discord server

Discord Unban All User command ( js )

Just a simple unban all users in guild command for my next ban royale in Discord. Any help would be greatly appreciated!
I wrote this based on the fact that you were writing your bot in discord.js as you did not give much information when writing and all i could see was the tags.
Try this-
const member = message.member;
switch(message.content.toLowerCase()){
case (!"unban all"):
if(member.hasPermission('ADMINISTRATOR')){
message.guild.fetchBans().forEach((fB)=>{
message.guild.members.unban(fB.user.id);
})
// All Users get unbanned
} else {
// User does not have permission.
}
}
})
If this does not work please let me know.
P.S. I'm kinda new to coding so if it is wrong please don't be angry with me.

avatarURL in an embed (.setThumbnail)

I would like an avatar URL of the person I tagged.
Unfortunately it doesn't work, I don't get an error. Code:
var user = message.mentions.members.first();
let embed = new Discord.MessageEmbed()
.setTitle("test")
.setDescription("test")
.setThumbnail(user.avatarURL)
.setTimestamp();
message.channel.send(embed);
}
I hope someone can help me! :-)
Try using:
user.displayAvatarURL()
Hope this helps!
I've found this example on the official documentation:
https://discord.js.org/#/docs/main/stable/examples/avatars
So maybe do:
message.author.displayAvatarURL()

Discord.js - Get Another Channel's Topic

I'm trying to basically do what the title says.
I've tried
let channel = message.channel.get(68352726916713XXXX)
message.channel.send(channel.topic)
and stuff like that, But nothing works.
Any suggestions or answers?
If you are trying to get a channel in the same guild as the message was sent in, use message.guild.channels.get. Otherwise, use client.channels.get.
let channel = message.guild.channels.get("68352726916713XXXX");
message.channel.send(channel.topic);

Resources