Skip to content

Commit

Permalink
[Update] updates and various fixes and code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Oct 5, 2021
1 parent 7e15f45 commit eb61ca9
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 10 deletions.
76 changes: 75 additions & 1 deletion commands/Admin/kick.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,85 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");
const { embedMessage } = require("../../modules/embedSimple");
const { getUserFromMention } = require("../../modules/getUserFromMention");

module.exports = {
name: "kick",
args: true,
description: "Kicks a user from the server",
usage: "kick <user> <reason>",
async run(message, args, client) {
const user = getUserFromMention(args[0], client);

if (!args[0])
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `❌ | Please mention a user to kick!`),
],
});

const noargs0 = args.shift();
const kickReason = args.join(" ");

const embed = {
author: {
name: `${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
color: "#9dcc37",
title: `A user has been kicked! ✅`,
fields: [
{
name: "User",
value: `${user}`,
inline: true,
},
{
name: "Reason",
value: `${kickReason}`,
},
],
timestamp: new Date(),
};

if (!message.member.permissions.has("KICK_MEMBERS"))
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | You do not have permission to kick members!`
),
],
});

if (!user)
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | Could not resolve the user, Please mention the user you want to kick!`
),
],
});

try {
await message.guild.members.kick(user, { kickReason });
await message.channel.send({ embeds: [embed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | Couldn't kick ${user}, ${error.message}`
),
],
});
}
},
data: new SlashCommandBuilder()
.setName("kick")
.setDescription("kicks a user from the server")
.setDescription("Kicks a user from the server")
.addUserOption((option) =>
option.setName("user").setDescription("Select a user").setRequired(true)
)
Expand Down
49 changes: 48 additions & 1 deletion commands/Admin/serverIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,56 @@ const { Permissions } = require("discord.js");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
name: "servericon",
aliases: ["si"],
description: "Changes the server icon!",
usage: "si || servericon <link must end with png or jpg>",
async run(message, args, client) {
if (!args[0])
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `❌ | Please provide a link to the new img!`),
],
});

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

try {
await message.guild.setIcon(args[0]);
await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ | Server Icon has been successfully changed!`
),
],
});
} catch (error) {
client.logger(error.message, "error");
await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | Could not change the server icon!, ${error.message}`
),
],
});
}
},
data: new SlashCommandBuilder()
.setName("servericon")
.setDescription("chnages the server icon!")
.setDescription("Changes the server icon!")
.addStringOption((option) =>
option
.setName("link")
Expand Down
67 changes: 66 additions & 1 deletion commands/Admin/unban.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,72 @@ const { Permissions } = require("discord.js");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
name: "unban",
args: true,
description: "",
usage: "unban",
async run(message, args, client) {
const userID = args[0];

if (!userID)
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | Please provide the user id of the user you wish to unban`
),
],
});

const noargs0 = args.shift();
const unbanReason = args.join(" ");

const embed = {
author: {
name: `${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
color: "#9dcc37",
title: `User unbanned successfully ✅`,
fields: [
{
name: "User ID:",
value: `${userID}`,
inline: true,
},
{
name: "Reason",
value: `${unbanReason}`,
},
],
timestamp: new Date(),
};

if (!message.member.permissions.has("ADMINISTRATOR"))
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | You do not have permission to unban members!`
),
],
});

try {
await message.guild.members.unban(userID, { unbanReason });
await message.channel.send({ embeds: [embed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`❌ | Couldn't ban <@${userID}>, ${error.message}`
),
],
});
}
},
data: new SlashCommandBuilder()
.setName("unban")
.setDescription("unbans a user with id")
Expand Down Expand Up @@ -64,7 +130,6 @@ module.exports = {
),
],
});
console.log(error);
}
},
};
4 changes: 2 additions & 2 deletions commands/Anime/highfive.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
await message.channel.send({ embeds: [highFiveEmbed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send(`Couldn't retrieve a hug gif, Sorry!`);
await message.channel.send(`❌ | Couldn't retrieve a hug gif, Sorry!`);
}
},
data: new SlashCommandBuilder()
Expand All @@ -47,7 +47,7 @@ module.exports = {
await interaction.followUp({ embeds: [highFiveEmbed] });
} catch (error) {
client.logger(error.message, "error");
await interaction.followUp(`Couldn't retrieve a hug gif, Sorry!`);
await interaction.followUp(`❌ | Couldn't retrieve a hug gif, Sorry!`);
}
},
};
4 changes: 2 additions & 2 deletions commands/Anime/hug.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
await message.channel.send({ embeds: [hugEmbed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send(`Couldn't retrieve a hug gif, Sorry!`);
await message.channel.send(`❌ | Couldn't retrieve a hug gif, Sorry!`);
}
},
data: new SlashCommandBuilder()
Expand All @@ -47,7 +47,7 @@ module.exports = {
await interaction.followUp({ embeds: [hugEmbed] });
} catch (error) {
client.logger(error.message, "error");
await interaction.followUp(`Couldn't retrieve a hug gif, Sorry!`);
await interaction.followUp(`❌ | Couldn't retrieve a hug gif, Sorry!`);
}
},
};
4 changes: 2 additions & 2 deletions commands/Anime/waifu.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
await message.channel.send({ embeds: [waifuEmbed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send(`Couldn't retrieve a waifu pic, Sorry!`);
await message.channel.send(`❌ | Couldn't retrieve a waifu pic, Sorry!`);
}
},
data: new SlashCommandBuilder()
Expand All @@ -47,7 +47,7 @@ module.exports = {
await interaction.followUp({ embeds: [waifuEmbed] });
} catch (error) {
client.logger(error.message, "error");
await interaction.followUp(`Couldn't retrieve a waifu pic, Sorry!`);
await interaction.followUp(`❌ | Couldn't retrieve a waifu pic, Sorry!`);
}
},
};
4 changes: 3 additions & 1 deletion commands/Anime/whatAnime.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module.exports = {
async run(message, args, client) {
if (!args[0])
return await message.channel.send({
embeds: [embedMessage("#9dcc37", `You have to provide an image link!`)],
embeds: [
embedMessage("#9dcc37", `❌ | You have to provide an image link!`),
],
});

try {
Expand Down

0 comments on commit eb61ca9

Please sign in to comment.