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:
First of all, next time wrap your code in codeblock please. Wrap it in triple backticks: ` code goes here ``​...
Jump to solution
2 Replies
Rumpelowy
Rumpelowy8mo ago
if I use /avatar then "the application does not respond" when I get a reply ping me
Solution
Favna
Favna8mo ago
First of all, next time wrap your code in codeblock please. Wrap it in triple backticks:

``​`
code goes here
``​`

``​`
code goes here
``​`
(note: a zero width space was used in this example, do not copy it 1:1) As for your problem,
registerApplicationCommands(registry) {
- registry.registerChatInputCommand((command) => {
+ registry.registerChatInputCommand((command) =>
command
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option
.setName("user")
.setDescription("Użytkownik do sprawdzenia")
.setRequired(false)
);
- });
+ );
}
registerApplicationCommands(registry) {
- registry.registerChatInputCommand((command) => {
+ registry.registerChatInputCommand((command) =>
command
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option
.setName("user")
.setDescription("Użytkownik do sprawdzenia")
.setRequired(false)
);
- });
+ );
}
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