README
Installation
npm i discord.js-advanced
Required Packages
- discord.js
- fs
- ms
- node-fetch
Setup
const discord = require("discord.js")
const fs = require("fs")
const ms = require("ms")
const fetch = require("node-fetch")
const client = new discord.Client()
//Most of this can be found in the Discord Developer Portal. Link: https://discord.com/developers/applications
const token = "your_token"
const clientID = "id_of_the_bot"
const clientSecret = "your_client_secret"
const supportServer = "your_bot_support_server"
const publicKey = "your_bot_public_key"
const ownerID = "your_id"
const perms = "perms_the_bot_needs"
const prefix = "your_prefix"
client.on('ready', () => {
console.log("Ready!")
client.user.setActivity(`${prefix}help`, { type: "LISTENING"} )
})
client.on('message', async (message) => {
// Here are the commands aka the if-functions, they can be found below
})
client.login(token)
Ping Command
if(message.content.toLowerCase().startsWith(`${prefix}ping`)){
const pingEmbed = new discord.MessageEmbed()
.setTitle(":ping_pong: Pong!")
.setColor("BLUE")
.setDescription(`${client.ws.ping} ms`)
.setTimestamp()
message.channel.send(pingEmbed)
}
Uptime Command
if(message.content.toLowerCase().startsWith(`${prefix}uptime`)){
let days = Math.floor(client.uptime / 86400000);
let hours = Math.floor(client.uptime / 3600000) % 24;
let minutes = Math.floor(client.uptime / 60000) % 60;
let seconds = Math.floor(client.uptime / 1000) % 60;
const uptimeEmbed = new discord.MessageEmbed()
.setTitle("Uptime")
.setColor("BLUE")
.setDescription(`${days}d ${hours}h ${minutes}m ${seconds}s`)
.setTimestamp()
message.channel.send(uptimeEmbed);
}
Help Command
if(message.content.toLowerCase().startsWith(`${prefix}help`)){
const helpEmbed = new discord.MessageEmbed()
.setTitle("Help Menu")
.setColor("BLUE")
.setThumbnail(client.user.displayAvatarURL())
.setDescription(":white_check_mark: - Here are the commands!\n:gear: - My Prefix is `--`")
.addFields(
{ name: "`ping`", value: `Get the ping of the Bot`},
{ name: "`uptime`", value: `Get the uptime of the Bot`}
)
.setTimestamp()
message.channel.send(helpEmbed)
}
Problems?
Join my Support Server
License
ISC
Author
@ Snowflake Studio | Jonas 2021