Skip to content

Commit

Permalink
[New] Added serverstats command to retrieve information about the gui…
Browse files Browse the repository at this point in the history
…ld the bot is into
  • Loading branch information
naseif committed Aug 30, 2021
1 parent f210edf commit 84787d0
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions commands/misc/serverstats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { SlashCommandBuilder } = require("@discordjs/builders");

module.exports = {
data: new SlashCommandBuilder()
.setName("serverstats")
.setDescription("Shows some stats about the server"),
async execute(interaction, client) {
await interaction.deferReply();
const guild = interaction.guild;

const statssEmbed = {
color: "#9dcc37",
title: `${guild.name}'s Stats`,
author: {
name: `${interaction.user.username}`,
icon_url: `${interaction.user.avatarURL()}`,
},
thumbnail: {
url: `${
guild.iconURL() ? guild.iconURL() : interaction.user.avatarURL()
}`,
},
fields: [
{
name: "Members",
value: `${guild.memberCount}`,
inline: true,
},
{
name: "Owner",
value: `<@${guild.ownerId}>`,
inline: true,
},
{
name: "Created",
value: `${guild.createdAt.toUTCString()}`,
},
],
timestamp: new Date(),
footer: {
text: "Created by naseif",
icon_url: "https://i.imgur.com/KrAvM8U.jpg",
},
};
try {
await interaction.followUp({ embeds: [statssEmbed] });
} catch (err) {
await interaction.followUp(
`I was not able to fetch the server info, do I have permission ?`
);
console.error(err);
}
},
};

0 comments on commit 84787d0

Please sign in to comment.