Skip to content

Commit

Permalink
Add new commands
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKowalczyk committed Apr 23, 2022
1 parent 9690cd1 commit 0635bf4
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bot/slash_commands/Moderation/modules/roles/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = async (client, interaction, args) => {
}),
})
.addField(`${client.bot_emojis.role} Role ID`, `> \`${role.id}\``)
.addField(`🎨 Color`, `> \`${role.hexColor}\``)
.addField(`${client.bot_emojis.color} Color`, `> \`${role.hexColor}\``)
.addField(`${client.bot_emojis.stage_channel} Mention`, `> <@&${role.id}>`)
.addField(`${client.bot_emojis.stopwatch} Date created`, `> <t:${Math.floor(role.createdTimestamp / 1000)}:F> (<t:${Math.floor(role.createdTimestamp / 1000)}:R>)`)
.addField(`${client.bot_emojis.member} Members `, `\`${role.members.size}\` members with this role`)
Expand Down
56 changes: 56 additions & 0 deletions bot/slash_commands/Utility/base64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const { MessageEmbed } = require("discord.js");

module.exports = {
name: "base64",
category: "Utility",
description: "🗃️ Encode or decode text to Base64 format",
usage: "/base64 <encode/decode> <text>",
container: true,
options: [
{
name: "encode",
description: "🗃️ Encode text to Base64 format",
type: 1,
usage: `/base64 encode <text>`,
category: "Utility",
orgin: "base64",
options: [
{
name: "text",
description: "The text to encode",
required: true,
type: 3,
}
]
},
{
name: "decode",
description: "🗃️ Decode Base64 text",
type: 1,
usage: `/base64 decode <text>`,
category: "Utility",
orgin: "base64",
options: [
{
name: "text",
description: "The text to decode",
required: true,
type: 3,
}
]

}
],
run: async (client, interaction, args) => {
try {
if(args[0] === "encode") {
require("./modules/base64/encode")(client, interaction, args);
} else if(args[0] === "decode") {
require("./modules/base64/decode")(client, interaction, args);
}
} catch (err) {
console.log(err);
return client.createSlashCommandError(interaction, err);
}
},
};
50 changes: 50 additions & 0 deletions bot/slash_commands/Utility/color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { Color, isColor } = require("coloras");
const { MessageEmbed } = require("discord.js");

module.exports = {
name: "color",
description: "🎨 Shows color info",
category: "Utility",
usage: "/color [color]",
options: [
{
name: "color",
description: "The color to show info about",
required: false,
type: 3,
}
],
run: async (client, interaction, args) => {
try {
!args[0] ? random = true : random = false;
if (!random && !isColor(args[0]).color) {
return client.createSlashError(interaction, `${client.bot_emojis.error} | Please provide a valid color`);
}
console.log(random)
const value = random ? null : args[0];
console.log(value)
const color = new Color(value);
const embed = new MessageEmbed() // Prettier
.setTitle(random ? `${client.bot_emojis.color} Random Color` : `${client.bot_emojis.color} Color: ${color.toHex()}`)
.addField("HEX", `> \`${color.toHex()}\``, true)
.addField("RGB",`> \`${color.toRgb()}\``, true)
.addField("HSL", `> \`${color.toHsl()}\``, true)
.addField("HSV", `> \`${color.toHsv()}\``, true)
.addField("CMYK", `> \`${color.toCmyk()}\``, true)
.setImage(color.imageUrl)
.setColor(color.toHex())
.setFooter({
text: `Requested by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({
dynamic: true,
format: "png",
size: 2048,
}),
});
interaction.followUp({ embeds: [embed] });
} catch (err) {
console.log(err);
return client.createSlashCommandError(interaction, err);
}
},
};
89 changes: 89 additions & 0 deletions bot/slash_commands/Utility/minecraft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const { MessageEmbed } = require("discord.js");
const fetch = require("node-fetch");

module.exports = {
name: "minecraft",
description: "🌳 Display minecraft server info",
category: "Utility",
usage: "/minecraft <server ip> [bedrock]",
container: true,
options: [
{
name: "server_ip",
description: "The IP of the server to get info about",
required: true,
type: 3,
},
{
name: "bedrock",
description: "Display bedrock info",
required: false,
type: 5
}
],
run: async (client, interaction, args) => {
try {
if (!args[0]) {
return client.createSlashError(interaction, `${client.bot_emojis.error} | Please enter a minecraft server IP!`);
}
if (!/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(:?[0-9]*)$/gim.test(args[0])) {
return client.createSlashError(interaction, `${client.bot_emojis.error} | Please enter a vaild minecraft server IP!`);
}
if (args[1]) {
fetch(`https://api.mcsrvstat.us/bedrock/2/${args[0]}`)
.then((res) => res.json())
.then((body) => {
if (body.ip == "127.0.0.1" || !body.ip) {
return client.createSlashError(interaction, `${client.bot_emojis.error} | Minecraft bedrock server not found!`);
}
const embed = new MessageEmbed() // Prettier
.setAuthor({ name: `${args[0]} (Bedrock)`, iconURL: `https://api.mcsrvstat.us/icon/${args[0]}` })
.setThumbnail(`https://api.mcsrvstat.us/icon/${args[0]}`)
.setFooter({
text: `Requested by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({
dynamic: true,
format: "png",
size: 2048,
}),
})
.setColor("#5865F2");
if (body.online.toString().length > 1) embed.addField(`${body.online ? client.bot_emojis.status_online : client.bot_emojis.status_dnd} ${body.online ? "Online" : "Offline"}`, `> \`${body.online ? "Online" : "Offline"}\``, true);
if (body.motd && body.motd.raw[0]) embed.setDescription(">>> " + body.motd.raw[0].replace(/§[0-9A-FK-OR]/gi, "").replaceAll("`", ""));
if (body.players && body.players.max && body.players.online) embed.addField(`${client.bot_emojis.member} Players`, `> \`${body.players.online}/${body.players.max}\``, true);
if (body.version) embed.addField(`${client.bot_emojis.stage_channel} Version(s)`, `> \`${body.version}\``, true);
interaction.followUp({ embeds: [embed] });
});
} else {
fetch(`https://api.minetools.eu/ping/${args[0].replace(":", "/")}`)
.then((res) => res.json())
.then((body) => {
if (body.error) {
return client.createSlashError(interaction, `${client.bot_emojis.error} | Minecraft server not found!\n\n**Tip:** If you want to check Bedrock server please use \`/minecraft <server ip> [bedrock=true]\``);
}
const embed = new MessageEmbed() // Prettier
.setAuthor({ name: args[0], iconURL: `https://api.mcsrvstat.us/icon/${args[0].replace(":", "/")}` })
.setThumbnail(`https://api.mcsrvstat.us/icon/${args[0].replace(":", "/")}`)
.setColor("#5865F2")
.setFooter({
text: `Requested by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({
dynamic: true,
format: "png",
size: 2048,
}),
});
if (body.description) embed.setDescription(`>>> ${body.description && body.description.length > 1 ? body.description.replace(/§[0-9A-FK-OR]/gi, "").replaceAll("\`", "") : "No description"}`);
if (body.players && body.players.max && body.players.online) embed.addField(`${client.bot_emojis.member} Players`, `> \`${body.players.online}/${body.players.max}\``, true);
if (body.latency) embed.addField(`${client.bot_emojis.status_online} Latency`, `> \`${body.latency}\``, true);
if (body.version && body.version.name) embed.addField(`${client.bot_emojis.stage_channel} Version(s)`, `> \`${body.version.name}\``, true);
embed.setTimestamp();
interaction.followUp({ embeds: [embed] });
});
}
} catch (err) {
console.log(err);
return client.createSlashCommandError(interaction, err);
}
},
};
28 changes: 28 additions & 0 deletions bot/slash_commands/Utility/modules/base64/decode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { MessageEmbed } = require("discord.js")

module.exports = async(client, interaction, args) => {
try {
if (args[1].toString().length > client.max_input) {
return client.createSlashError(interaction, `${client.bot_emojis.error} | You must enter a text shorter than \`${client.max_input}\` characters!`);
}
const buffer = new Buffer.from(args[1], "base64");
const base64 = buffer.toString("utf-8");
const embed = new MessageEmbed()
.setColor("#5865F2")
.setFooter({
text: `Requested by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({
dynamic: true,
format: "png",
size: 2048,
}),
})
.setTitle(`${client.bot_emojis.sparkles} Base64 Encode`)
.addField(`${client.bot_emojis.input} Text to encode`, `\`\`\`${args[1]}\`\`\``)
.addField(`${client.bot_emojis.output} Encoded text`, `\`\`\`${base64 || "An unknown error ocurred while encoding!"}\`\`\``);
interaction.followUp({ embeds: [embed] });
} catch (err) {
console.log(err);
return client.createSlashCommandError(interaction, err);
}
}
28 changes: 28 additions & 0 deletions bot/slash_commands/Utility/modules/base64/encode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { MessageEmbed } = require("discord.js")

module.exports = async(client, interaction, args) => {
try {
if (args[1].toString().length > client.max_input) {
return client.createSlashError(interaction, `${client.bot_emojis.error} | You must enter a text shorter than \`${client.max_input}\` characters!`);
}
const buffer = new Buffer.from(args[1], "utf-8");
const base64 = buffer.toString("base64");
const embed = new MessageEmbed()
.setColor("#5865F2")
.setFooter({
text: `Requested by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({
dynamic: true,
format: "png",
size: 2048,
}),
})
.setTitle(`${client.bot_emojis.sparkles} Base64 Encode`)
.addField(`${client.bot_emojis.input} Text to encode`, `\`\`\`${args[1]}\`\`\``)
.addField(`${client.bot_emojis.output} Encoded text`, `\`\`\`${base64 || "An unknown error ocurred while encoding!"}\`\`\``);
interaction.followUp({ embeds: [embed] });
} catch (err) {
console.log(err);
return client.createSlashCommandError(interaction, err);
}
}
1 change: 1 addition & 0 deletions config/emojis_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@ module.exports = {
arrows_clockwise: "🔃",
jigsaw: "🧩",
wave: "👋",
color: "🎨",
};
1 change: 0 additions & 1 deletion dashboard/templates/status.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function format({time: time, element: element}) {
};
const start = <%= moment(timestamp).unix() %>;
var el = document.getElementById("uptime");
console.log(el)
setInterval(function () {
format({time: new Date().getTime() / 1000 - start, element: el});
}, 1000);
Expand Down

0 comments on commit 0635bf4

Please sign in to comment.