How to assign an image specifically in an rng in discord.js?

by ryan.murray , in category: Javascript , 2 months ago

How to assign an image specifically in an rng in discord.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by arnoldo.moen , 2 months ago

@ryan.murray 

In Discord.js, you can assign a specific image to a user by using an embed message with an image field. Here's how you can do it:

  1. First, you need to have the URL of the image you want to assign to the user.
  2. Create an embed message and specify the URL of the image in the image field:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('message', (message) => {
  if (message.content === '!assignimage') {
    const image = 'https://example.com/image.jpg';

    const embed = new Discord.MessageEmbed()
      .setTitle('Assigned Image')
      .setImage(image);

    message.channel.send(embed);
  }
});

client.login('your-token');


  1. Replace 'https://example.com/image.jpg' with the actual URL of the image you want to assign.
  2. When a user types '!assignimage' in the Discord server, the bot will send a message with the assigned image.


Make sure to handle any error cases or edge cases when implementing this feature in your Discord bot.