The embed message in Discord.js bot is failing to display the bot's avatar

Hey there! Currently working on my own Discord bot and looking to implement the command !botinfo.

When I enter this command, the goal is for it to display an embedded message in my channel. However, everything seems to be functioning properly except for one issue - the Discord bot avatar isn't showing up. Can anyone provide some assistance with this?

if (command === `${prefix}botinfo`) {

    var botIcon = new bot.user.displayAvatarURL;

    var botEmbed = new discord.MessageEmbed()
        .setDescription("Discord bot info")
        .setColor(0xF1C40F)
        .setThumbnail(botIcon)
        .addField("Bot name", bot.user.username);

return message.channel.send(botEmbed);

The specific error message that I'm encountering is ->

bot.user.displayAvatarURL is not a constructor

Answer №1

Avoid using the new keyword when calling methods (or properties). It should only be used for creating new object instances.

var botIcon = bot.user.displayAvatarURL();

Answer №2

I managed to figure it out

if (command === `${prefix}botinfo`) {


        var botEmbed = new discord.MessageEmbed()
            .setDescription("Bot Information")
            .setColor(0xF1C40F)
            .setThumbnail(bot.user.displayAvatarURL())
            .addField("Name of the Bot", bot.user.username, true)
            .addField("Version", version, true)
            .addField("Creator", creator)

            return message.channel.send(botEmbed);
    }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhance user experience with a unique slideToggle method that does not rely on the height of

Show some hidden content using the jQuery slideToggle method when clicking on a title: $(".main-section .main-section-title").click(function() { $(this) .parent() .next(".content") .slideToggle(500, "linear"); }); <script src="https://c ...

Submitting a POST request to paginate and sort the results

Currently, I have a system in place where a GET request is used to query the database and display the results. While this method works well, I am looking to transition it into a POST request. This would allow for a more flexible approach by handling JSON b ...

Is it possible to set functions as variables within an if statement in JavaScript and then not be able to call them later?

My validation process involves a multi-function where I don't invoke a master function beforehand to check and validate inputs. Within my "SignUp Function", I have implemented a validation function as variables that are checked before passing to the r ...

Using an AngularJS module in Angular is a seamless process that can add functionality to

Currently, I am looking to implement a card carousel in my Angular 13 project. I've been searching for a simple carousel module that doesn't rely on bootstrap (since I'm using Bulma), jquery, or any unnecessary dependencies and came across t ...

Having trouble with manipulating fabric.js objects within react.js

Currently, I have integrated the fabric.js library into my React application. https://www.npmjs.com/package/fabric In my project, I have successfully added a simplistic yellow rectangle to the canvas using fabric. The yellow rectangle displays correctly ...

Strategies for accessing a collection of DOM elements in React

Currently, I'm embarking on a challenge to complete 50 projects in 50 days by Brad Traversy. However, I've decided to take it up a notch by building them in Next.js with React since that's what I work with professionally. Unfortunately, thi ...

I am interested in implementing bxslider within a nuxt.js environment powered by vue.js

Created using nuxt.js, I am looking to incorporate a slider on my website and hoping to use bxslider for this purpose. Below is the code snippet from nuxt.config.js: head: { script: [ {type: 'text/javascript', src: 'https://cdnjs.clo ...

How to disable the next button in jQuery when a radio button is not checked, specifically for the first element

On my website, I have a series of questions with radio button answers. I want the user to only proceed to the next question once they have selected a radio button for the current question. Below is the code I have implemented: $('div.question' ...

Implementing JQuery techniques to dynamically insert separate content into elements sharing the same class

I have utilized django to establish a model company featuring attributes like name and address. I aim to exhibit solely the names of all companies in the query-set. My desire is for jquery to unveil the corresponding address upon clicking the name (via aja ...

An unexpected import token was encountered while using ReactJS and Babel

Every time I attempt to launch my application, an error message pops up that says: (function (exports, require, module, __filename, __dirname) { import { Row } from '../grid' SyntaxError: Unexpected token import I've experimented with vari ...

What is the process for including the posting date in the JSON format while using the Instagram

Struggling to incorporate the date into my JSON Instagram feed has been a challenge for me. For reference, here is a demonstration on JSFiddle: http://jsfiddle.net/galnova/p74jy3sk/ The following code snippet includes the commented-out section related to ...

Retrieve Image/png using an Extjs ajax request

Hello, I am currently working on an application that is designed to showcase dynamically generated images stored on a server. The process involves fetching the image, typically in PNG format, using an Ajax Request. The data retrieved appears as follows: ...

Ensuring that files adhere to the required format, whether they be images

Three separate input fields are being used, each with its own name for identification. A validation method is called to ensure that the files selected in these input fields are not duplicates and that they are either images or PDFs but not both. While thi ...

Chrome will automatically retry an AJAX POST request if it times out after 10 seconds

I am in the process of creating a React JavaScript application using a back end powered by Node.js and Express. The software versions being used are as follows: React: ^16.0.0 Node: v8.0.0 Express: ^4.14.0 Chrome: Version 63.0.3239.84 (Official Build) (64 ...

Is it possible to swap out images using srcset attribute?

Currently, I am facing an issue regarding changing the img on mobile and tablet devices to display different images. As a beginner with jQuery, I couldn't resolve it using that framework, so I am exploring options with html5. I am wondering if there ...

Absolute positioned content causing unexpected spacing on top of relative positioned content

I've been experimenting with a fantastic technique by Chris Coyier for implementing full page video backgrounds with content scrolling over the video. However, I've encountered an issue where there's an unexpected gap to the right in Windows ...

When the menu active item is clicked, the header will automatically scroll to the top

I've implemented a sticky header using CSS and JavaScript along with a mega menu. However, I've encountered an issue where when scrolling to the bottom and clicking on the "more" link in the dropdown, the page scrolls back to the top. This is the ...

JavaScript dropdown menu that dynamically changes colors

<!DOCTYPE html> <html> <head> </head> <body> <script> var redtoggle=false; function togglered() { redtoggle = !redtoggle; if (redtoggle) { document.getElementById("txtInput").style.color = "red"; } else { do ...

How can I alter the div once the form has been submitted?

Is there a way to change the background of a form and its results after submitting the form? I need to switch the image background to a plain color. I attempted to use a solution I found, but it doesn't seem to be working as expected. You can view my ...

Having trouble retrieving data when updating a user in ExpressJS

Trying to update an experience array in the User model with new data, but facing issues with saving the data in the exec function. As a result, unable to push the new data to the array on the frontend. Here is the current code snippet: router.post('/ ...