Ask Your Question
3

Can selfbot messages in discord.js have locally uploaded images attached to them?

asked 2022-08-26 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-14 04:00:00 +0000

huitzilopochtli gravatar image

Yes, selfbot messages in discord.js can have locally uploaded images attached to them. You can use the Discord.MessageAttachment class to attach local files to message objects. Here's an example:

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log('I am ready!');
});

client.on('message', message => {
  if (message.author.bot) return; // ignore bot messages
  if (!message.content.startsWith('!')) return; // only respond to commands
  const args = message.content.slice(1).split(' ');
  const command = args.shift().toLowerCase();

  if (command === 'image') {
    const attachment = new Discord.MessageAttachment('path/to/local/image.png');
    message.channel.send(attachment);
  }
});

client.login('your_token_here');

In this example, the image command sends the locally uploaded image path/to/local/image.png as an attachment to the channel where the command was invoked.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-08-26 11:00:00 +0000

Seen: 10 times

Last updated: Jan 14 '22