Skip to content

Commit

Permalink
[New] Added a command to change server icon!
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Sep 16, 2021
1 parent 99410a7 commit 887a0b5
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions commands/admin/serverIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
data: new SlashCommandBuilder()
.setName("servericon")
.setDescription("chnages the server icon!")
.addStringOption((option) =>
option
.setName("link")
.setDescription("the link of the new img, must end with png or jpg!")
.setRequired(true)
),
async execute(interaction, client) {
await interaction.deferReply();
const newIcon = interaction.options.getString("link");

if (
!interaction.member.permissions.has([Permissions.FLAGS.MANAGE_GUILD]) ||
!interaction.member.permissions.has([Permissions.FLAGS.ADMINISTRATOR])
)
return await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`${interaction.user.toString()}, You do not have permission to change the server icon!`
),
],
});

try {
await interaction.guild.setIcon(newIcon);
await interaction.followUp({
embeds: [
embedMessage("#9dcc37", `Server Icon has been successfully changed!`),
],
});
} catch (error) {
await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`Could not change the server icon!, ${error.message}`
),
],
});
}
},
};

0 comments on commit 887a0b5

Please sign in to comment.