0
votes

I am not very experienced in javascript and I have a problem to display my attached image. when someone type #1 bot send an embed with caracteristics and i want post the image too ! I don't know if I formatted it wrong or if I should load the image first. So the image is my local folder in the same directory as my index.js file

I had problems with color too! I didn't manage to modify it! I didn't manage to modify it I would have liked to be able to change the color of the name title or description but I don't know if it's possible my tests were unsuccessful Could you help me a little bit please? Here is my code. Thanks in advance.

const { token, prefix } = require('../config.json');


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


// Listen to the Bot being ready
client.once('ready', () => onClientReady());

function onClientReady()
    {
        // Listen to Messages in the channel
        client.on('message', (message) => onMessageReceived(message));
    }

    // Upon a message being received, handle how we interact
function onMessageReceived(message)
{    
    if(message.author.bot) return;
    if (message.content.toLowerCase().includes('#1'))
    message.channel.send({ embed: {
        color: 3447003,
        title: "SpaceShips #1 New_York",
        url: "http://google.com",
        description: "RANK: 74 / SCORE: 121",
        Thumbnail: (url="attachment://000793.jpg"),
       fields: [{
           name: "__**POWER**__",
           value: "A-G 0: **39**",
           "inline": true
          },
         {
           name: "__**POWER**__",
           value: "E-W: **76**",
               "inline": true
         },
         {
           name: "__**AUTONOMY**__",
           value: "EY-W Nrg: **74**",
               "inline": true
         },
         {
           name: "__**AUTONOMY**__",
           value: "B-P 0 Nrg: **73**",
               "inline": true
          },
         {
           name: "__**DISPLACEMENT**__",
           value: "L-A: **79**",
           "inline": true
          },
         {
           name: "__**DISPLACEMENT**__",
           value: "3D-V: **67**",
               "inline": true
         },
         {
           name: "__**SPECIALS**__",
           value: "EM-W: **34**",
               "inline": true
          },
         {
           name: "__**SPECIALS**__",
           value: "3D-W: **42**",
               "inline": true
          }
        ],
      }
    });
}


client.login(token);
4
This is JavaScript, not Python. - Jonathan Feenstra
my bad... sorry... corrected - Phil

4 Answers

0
votes

If your working with python, and just want to send an image, try this:

await channel.send(file=discord.File('my_image.png'))
0
votes

You may simply add an image value to the embed object you're sending like so:


message.channel.send({ embed: {
        color: 3447003,
        title: "SpaceShips #1 New_York",
        url: "http://google.com",
        description: "RANK: 74 / SCORE: 121",
        thumbnail: { 
        url: "attachment://000793.jpg"
         },
      }
    }); // Removed fields to clear up the clutter, you may add them like before!

As far as color is concerned it's a RGB value you may Google up the value for the colour you like and replace it!

0
votes

If you want only send the image then here i suppose (Node.Js)

const path = require('path');
const Discord = require('discord.js');

let pic = path.resolve('test.jpg') 
// the picture, if you console.log it will send the path of the file for example mine /src/image/test.jpg

message.channel.send(new Discord.MessageAttachment(pic))
0
votes

In fact it isn't possible in local to put an image in a embed... we only can put attach file... Si I used an web link and hosted my images on a server and it works! Thanks for your help.