I have a problem
avatar.js not working
code :
const { Command } = require("@sapphire/framework");
const { MessageAttachment } = require("discord.js");
class AvatarCommand extends Command {
constructor(context, options) {
super(context, {
...options,
name: "avatar",
description: "Pobierz avatar użytkownika"
});
}
registerApplicationCommands(registry) {
registry.registerChatInputCommand((command) => {
command
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option
.setName("user")
.setDescription("Użytkownik do sprawdzenia")
.setRequired(false)
);
});
}
async chatInputRun(interaction) {
const user = interaction.options.getUser("user") || interaction.user;
const avatarURL = user.displayAvatarURL({ format: "png", size: 2048 });
const attachment = new MessageAttachment(avatarURL);
return interaction.reply({
content:
Avatar użytkownika **${user.username}**
,
files: [attachment],
});
}
}
module.exports = {
AvatarCommand,
};Solution:Jump to solution
First of all, next time wrap your code in codeblock please. Wrap it in triple backticks:
`
code goes here
``
...2 Replies
if I use /avatar then "the application does not respond"
when I get a reply ping me
Solution
First of all, next time wrap your code in codeblock please. Wrap it in triple backticks:
(note: a zero width space was used in this example, do not copy it 1:1)
As for your problem,
You're using arrow functions incorrectly. Learn about the difference between having and not having wrapping
{ }
https://www.w3schools.com/Js/js_arrow_function.asp