Discord.js v12 image in message embed - discord

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.

Related

Discord: Reading messages from one channel in a (non-admin perm) server, and posting it to another (with admin perms)

I am new to Discord API framework.
ServerFROM is a public server that I was invited to (non-admin perms). Hence I cannot add bots there. But I can view the content in ChannelFROM (a text channel in ServerFROM)
I have my own ServerTO (in which I have admin perms and so can do anything). Inside of which, I have the target ChannelTO
I want to deploy a listener on ChannelFROM, such when there is a new message (announcement) in ChannelFROM, I want it to be read and reposted in ChannelTO.
Something similar to what is done in this Stackoverflow issue, except that I cannot have some script run locally 24x7 on my machine. Maybe use Github Actions or something similar?
How can I go about doing it? Any ideas are appreciated. Maybe some form of a server, or just a custom Discord bot
And thanks in advance.
you can use Custom bot for that. I dont know other way
here's how i do it
1st : We Get the ID of the Channel that you wanted to listen
2nd : We make a Output or where the bot copy the message from and send it
3rd : Bot required a permission to view the channel and send message
or in the nutshell ( sorry if im bad at explaining )
client.on("messageCreate", message => {
if(message.author.bot) return;
if(message.channel.id === ID_HERE) // ChannelFROM in ID_HERE
{
let MSG = message.content
let Author = message.member.displayName
let Avatar = message.author.displayAvatarURL({dynamic: true})
const Embed = new MessageEmbed()
.setAuthor(Author , Avatar )
.setDescription(MSG)
.setColor("RANDOM")
client.channels.cache.get(ID_HERE).send({ embeds: [Embed] }) // SendTo in ID_HERE
}
})
you can remove if(message.author.bot) return; if you want it also read other bot message on that specific channel

Redirect to a channel as well as ping a role then post a message using args

I'm making an announcement command for my bot and want it to go to the announcements channel automatically, then ping the first role mentioned and finally display the message.
For now I have it going to staff commands as a placeholder to get it working, this does not work or throw an error. It properly pings the role, but nothing after that shows up, even the "Debug". What am I missing. I've seen the channel part work but it doesn't for me, and I can't find a similar situation online for the message itself.
module.exports.run = async (client, message, args) => {
if (message.author.bot) return;
let prefix = config.prefix;
if(!message.content.startsWith(prefix)) return;
const channel = message.guild.channels.cache.find(c => c.name === '🚔|staff-cmds');
let pingRole = message.mentions.roles.first();
let messageContent = args.slice(1).join(' ');
channel.send(pingRole, messageContent, "Debug");
This is what happens when the command is run
Try this channel.send(`${pingRole} ${messageContent}`)
The channel.send() function takes only two parameter "content" and "options" you can read more about it here

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

how to make it so that if a message is dm'ed a bot the message is shown in a channel in server discord.js

I need help making a discord bot so that if a message is dm'ed a bot the message is shown in a channel in server discord.js
A very basic way to do this is to just see if the message channel type is a DM (if (message.channel.type === 'dm')), and if it is, we will send the message content to a certain channel (client.channels.cache.get('channel_id').send(message.content)).
Put together, it is like this:
if (message.channel.type === 'dm') {
client.channels.cache.get('channel_id').send(message.content)
}
That will only send the message content.If you want to see who sent the message, you can do something like this:
client.channels.cache.get('channel_id').send(`New message by ${message.author.tag}: ${message.content}`)
This well send you something like New message by Username#0000: Hello world!.(This is a good place to stop if you want a simple if statement that gets who sent it and the message content.)
We can then go on to create this as an embed:
var dmMessage = new Discord.MessageEmbed() // This creates an empty embed
.setTitle("New DM!") // This sets the title of the embed to 'New DM!'
.setDescription(`**New message from ${message.author.tag}**(${message.author.id})\n**Message content**: ${message.content}`) // This is the main text of the embed
.setColor("GREEN") // This sets the color of the embed. It can be RED, PURPLE, etc. or it can be a hex code
.setTimestamp() // This shows the time when the embed was sent. ( it would also be the time the message was sent )
.setFooter(client.user.tag, client.user.displayAvatarURL()) // This sets the bots tag and profile picture to the footer
.setAuthor(message.author.tag, message.author.displayAvatarURL({dynamic: true})) // This sets the 'author' of the embed. It will show up at the top of the embed. The {dynamic: true} just makes it animate the profile photo if it is animated
if (message.channel.type === 'dm') {
client.channels.cache.get('channel_id').send(dmMessage) // Sends the embed to the specified channel ID
}
You can always create a variable like var dmID = "your_channel_id" and replace the 'channel_id' in the client.channels.cache.get with dmID so you can change the variable and it will change everywhere.

Discord.js Bot that can send a embed message

I will refer to this picture:
I am making a Discord bot in JavaScript and I am stuck somewhere
I have a say command which you use like !say Text here and the bot will send a plain message saying Text here
Now I want the bot to send an embed message used the same and I want the bot to have a title, image, link and a author set on default. When someone does !sayEmbed #everyone loco (the text there)
There you go:
client.on("message", function(msg){
if (msg.content.split("!")[0] != "sayEmbed") return;
if (msg.content.split(" ")[1]){
// if args exist
msg.channel.send(new MessageEmbed()
.setTitle("Genius Mind")
.setDescription(msg.content.split("!sayEmbed")[0])
.setColor("#148837")
.setAuthor(`#everyone react now | {msg.createdAt.toDateString}`)
.setURL("someURL.example.com")
.setThumbnail("foo.bar/link/to/image")
)
}
}
I couldn't find any url and image url, so change that yourself.

Resources