Basically Im trying to create a Avatar command, but its show me the avatar but the image resolution are bad. so how do I fix it?
Here's my code
module.exports = {
name: "avatar",
aliases: ["icon", "pfp"],
category: "Fun",
description: "Return A User Avatar!",
usage: "Avatar | <Mention Or ID>",
run: async (client, message, args) => {
const Member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;
const Embed = new Discord.MessageEmbed()
.setDescription(message.author.tag + " 's Avatar")
.setColor("#800000")
.setImage(Member.user.displayAvatarURL({size: 1024, dynamic: true}))
.setFooter(`Requested By ${message.author.username}`)
.setTimestamp();
return message.channel.send(Embed);
}
};
module.exports.config = {
name: 'avatar',
description: 'do a avatar',
usage: 'avatar',
botPerms: [],
userPerms: [],
aliases: ['av'],
};
.setImage(Member.user.displayAvatarURL({size: 1024, dynamic: true}))
Try 256 or 512 instead. It actually depends on the user's avatar itself.
ImageURLOptions
MessageEmbedImage
Related
const { Client, CommandInteraction, EmbedBuilder, Permissions, ApplicationCommandType } = require("discord.js");
const { Formatters } = require('discord.js');
const blacklistedWords = require("../../Collection/index.js");
const Schema = require('../../models/blacklist.js')
module.exports = {
name: "blacklist_add",
description: "add a word to blacklist so that the members of the server cannot use the word",
userPerms: ['Administrator'],
type: ApplicationCommandType.ChatInput,
options: [{
name: 'word',
description: 'word to be added to the blacklist',
type: 3,
required: true
}],
/**
*
* #param {Client} client
* #param {CommandInteraction} interaction
* #param {String[]} args
*/
run: async (client, interaction, args) => {
const sword = interaction.options.getString('word');
console.log(sword)
const word = sword.toLowerCase();
const guild = { Guild: interaction.guild.id }
Schema.findOne(guild, async(err, data) => {
if(data) {
if(data.Words.includes(word)) return interaction.followUp(`The word already exists in the blacklist did you mean to remove it if so please use /blacklist-remove ${word} to remove the word from blacklist`)
data.Words.push(word)
data.save();
blacklistedWords.get(interaction.guild.id).push(word);
}else {
new Schema({
Guild: interaction.guild.id,
Words: word
}).save();
blacklistedWords.set(interaction.guild.id, [ word ])
}
const embed = new EmbedBuilder()
.setTitle('<:donetick:951395881607893062> Blacklist system')
.setColor('GREEN')
.setDescription('Word added- A new word has been added to the blacklist')
.addField('Word', `${word}`, false)
.addField('How do I remove the word from the blacklist?', `/blacklist-remove ${word}`, false)
interaction.reply({ embeds: [embed] })
});
},
};
this is the code but it used to work with djs v13 idk now why is it giving this error
the error image in console
can you please help I am new to djs v14 so I think that is an error caused by upgrading to v14 correct me if wrong
How should I add buttons who can edit embed reply like: β¬
οΈπ β‘οΈ when I press β‘οΈ then it update the embed and shows me the next page like that and when I press π button it shoud let me on home page
const { Client, CommandInteraction, MessageEmbed, MessageActionRow, MessageButton, MessageAttachment, MessageCollector, MessageSelectMenu } = require('discord.js');
const ee = require("../../config/embed.json")
const em = require("../../config/emojis.json")
module.exports = {
name: 'help',
description:'shows help commands',
userperm: [],
botperm: [],
ownerOnly: false,
/**
#param {Client} client
#param {CommandInteraction} interaction
#param {String[]} args
*/
run: async (client, interaction, args) => {
const serverinvite = `https://discord.gg/euf5mqAMmM`;
const inviteUrl = `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=8&scope=bot%20applications.commands`;
const embed = new MessageEmbed()
.setTitle('Suggetions Commands')
.setDescription(`This bot is totally in slash so try the commands in slash only`)
.setColor('RANDOM')
.setTimestamp()
.addFields(
{ name: 'Suggetion Commands', value: '`suggetion set` , `suggest` , `suggetion reset`' },
{ name: 'Utilities Commands', value: '`/poll`' },
{ name: 'Info Commands', value: '`help` , `invite` , `vote` , `ping`', inline: true },
)
.setThumbnail(client.user.displayAvatarURL())
.setFooter({ text: client.user.tag , gif: 'https://media.discordapp.net/attachments/1004409670556979232/1004919770220601544/standard_7.gif'})
.setImage('https://media.discordapp.net/attachments/1017764767244505190/1017793760937123971/standard_10.gif')
const actionRow = new MessageActionRow()
.addComponents([
new MessageButton()
.setLabel('Invite')
.setURL(inviteUrl)
.setStyle("LINK")
])
.addComponents([
new MessageButton()
.setLabel('Support server')
.setURL(serverinvite)
.setStyle("LINK")
])
interaction.followUp({ embeds: [embed], components: [actionRow] })
}
}
So I'm building a bot with discord.js, but I'm having trouble sending commands that include embed. I can send text commands easily, such as purge, ping, time and so on, but having trouble with embeds.
This is my index.js file
const keepAlive = require('./server');
const Discord = require('discord.js');
const client = new Discord.Client();
var { readdirSync } = require('fs');
client.config = require('./config.js');
client.commands = new Discord.Collection();
for(const file of readdirSync('./commands/')) {
if(!file.endsWith(".js")) return;
var fileName = file.substring(0, file.length - 3);
var fileContents = require(`./commands/${file}`);
client.commands.set(fileName, fileContents);
}
for(const file of readdirSync('./events/')) {
if(!file.endsWith(".js")) return;
var fileName = file.substring(0, file.length - 3);
var fileContents = require(`./events/${file}`);
client.on(fileName, fileContents.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
}
client.login(client.config.token)
.then(() => {
if(!client.user.bot) { console.log("[JPBTips] Don't self bot idot"); return process.exit() };
console.log(`Client logged in as ${client.user.tag}`);
})
.catch((err) => {
console.error("Error while logging in: " + err);
if(err.toString().match(/incorrect login details/gi)) console.log("Make sure to change up your config!");
});
keepAlive();
And then this is my message.js code:
module.exports = (client, message) => {
if(!message.content.startsWith(client.config.prefix)) return;
if(message.author.bot) return;
const args = message.content.slice(client.config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase()
var cmd = client.commands.get(command);
if(!cmd) return;
cmd(client, message, args);
}
You should take a look at the docs for the embedBuilder
If you are using discord.js v14 you should use const { EmbedBuilder } = require('discord.js');
and if you are using discord.js v13 use const { EmbedBuilder } = require('#discordjs/builders');
That means your command file (located in your commands folder) should look something like this:
const { EmbedBuilder } = require('discord.js'); //depending on your discord.js version (this example is for v14)
exports.run = (client, message) => {
const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/AfFp7pu.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addFields({ name: 'Inline field title', value: 'Some value here', inline: true })
.setImage('https://i.imgur.com/AfFp7pu.png')
.setTimestamp()
.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });
message.reply({ embeds: [exampleEmbed] });
}
And in your message.js file you have to replace cmd(client, message, args) with cmd.run(client, message, args);
Please let me know if this works out for you and have a great vacation
can you show the file where you're trying to reply with an embed ?
Maybe the problem (without seeing your code) is:
You're writing: message.reply(embed);
But since V13 it's: message.reply({ embeds: [embed] });
I'm currently working on a kick command (following reconlx's Kick, Ban, and Unban command tutorial). All commands stop working (including the kick command).
If anyone can take a look, it'd be helpful.
Code for kick.js and the error is down below.
const { MessageEmbed, Message } = require("discord.js");
module.exports = {
name: 'kick',
description: 'Kicks a member',
userPermissions: ["KICK_MEMBERS"],
options: [
{
name: "member",
description: "The member you wish to kick",
type: "USER",
required: true
},
{
name: "reason",
description: "Reason for kicking",
type: "STRING",
required: false
},
],
/**
* #param {Client} client
* #param {CommandInteraction} interaction
* #param {String[]} args
*/
run: async (client, interaction, args) => {
const target = interaction.options.getMember("target");
const reason =
interaction.options.getString("reason") || "No reason(s) provided";
const rolePositionCheck = new MessageEmbed()
.setTitle("You can't kick a person with a higher role than yours!")
.setFooter({ text: "Error: Lower Role Position"})
if (
target.roles.highest.position >=
interaction.member.roles.highest.position
)
return interaction.followUp({
embeds:
[rolePositionCheck],
});
// Message which is sent to the person kicked
const kickMessage = new MessageEmbed()
.setTitle(`You've been kicked from ${interaction.guild.name}`)
.setFooter({ text: `Reason: ${reason}` })
await target.send({ embeds: [kickMessage] });
// The action of kicking, along with the reason
target.kick(reason)
// Message which is sent to the mod who kicked.
const kickAftermath = new MessageEmbed()
.setTitle(`${target.user.tag} has been kicked!`)
.setFooter({ text: `${reason}` })
interaction.followUp({
embeds:
[kickAftermath],
});
},
};
Error
TypeError: Cannot read properties of null (reading 'roles')
at Object.run (C:\Users\admin\Desktop\Tonkotsu\SlashCommands\moderation\kick.js:38:20)
at Client.<anonymous> (C:\Users\admin\Desktop\Tonkotsu\events\interactionCreate.js:27:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I have a Server Info command which worked in v12 but I updated to v13. In v12 when I send the Command it Responds with the correct region but in v13 when I send the command, responds at server region with undefined, help!
This is server info command:
const Discord = require('discord.js');
module.exports = {
name: "serverinfo",
aliases: ["si"],
description: "Shows all Info about the Server!",
execute: async (message, args, client) => {
let region;
switch (message.guild.region) {
case "europe":
region = 'πͺπΊ europe';
break;
case "russia":
region = 'π·πΊ russia';
break;
case "us-east":
region = 'πΊπΈ us-east'
break;
case "us-west":
region = 'πΊπΈ us-west';
break;
case "us-south":
region = 'πΊπΈ us-south'
break;
case "us-central":
region = 'πΊπΈ us-central'
break;
}
const embed = new Discord.MessageEmbed()
.setThumbnail(message.guild.iconURL({dynamic : true}))
.setColor('#dd6fb9')
.setTitle(`**Bot Command**`)
.setFooter("#" + message.author.tag, message.author.displayAvatarURL({dynamic : true}))
.addFields(
{
name: `Region: `,
value: `${region}`,
inline: true
}
await message.channel.send( { embeds: [embed] }).then(setTimeout(() => message.delete())).then(msg =>{
setTimeout(() => msg.delete(), 120000)});
},
};
A guild no longer has the attribute region. You can however get the preferredLocale of the server:
const Discord = require('discord.js');
module.exports = {
name: "serverinfo",
aliases: ["si"],
description: "Shows all Info about the Server!",
execute: async (message, args, client) => {
const embed = new Discord.MessageEmbed()
.setThumbnail(message.guild.iconURL({dynamic : true}))
.setColor('#dd6fb9')
.setTitle(`**Bot Command**`)
.setFooter("#" + message.author.tag, message.author.displayAvatarURL({dynamic : true}))
.addFields(
{
name: `Region: `,
value: `${message.guild.preferredLocale}`,
inline: true
}
await message.channel.send( { embeds: [embed] }).then(setTimeout(() => message.delete())).then(msg =>{
setTimeout(() => msg.delete(), 120000)});
},
};