-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] Added serverstats command to retrieve information about the gui…
…ld the bot is into
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}, | ||
}; |