summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authorSin-MacBook <[email protected]>2020-08-17 15:37:36 +0200
committerSin-MacBook <[email protected]>2020-08-17 15:37:36 +0200
commit752296a41a19a59fa4f241ef534b61c607a2b377 (patch)
tree3f4acd2fd60bb252dfb174877447cfa2a2db1f5f /server/src
parentenhance: refactor, add duck (thx van) (diff)
downloaddep-core-752296a41a19a59fa4f241ef534b61c607a2b377.tar.xz
dep-core-752296a41a19a59fa4f241ef534b61c607a2b377.zip
feat: mcss and serverlist cmd + small fix
Diffstat (limited to 'server/src')
-rw-r--r--server/src/commands/fun/MinecraftServerStatus.ts71
-rw-r--r--server/src/commands/owner/ServerList.ts30
-rw-r--r--server/src/listeners/client/message.ts2
3 files changed, 102 insertions, 1 deletions
diff --git a/server/src/commands/fun/MinecraftServerStatus.ts b/server/src/commands/fun/MinecraftServerStatus.ts
new file mode 100644
index 0000000..064f137
--- /dev/null
+++ b/server/src/commands/fun/MinecraftServerStatus.ts
@@ -0,0 +1,71 @@
+import { Command } from 'discord-akairo';
+import { Message, MessageAttachment } from 'discord.js';
+import Axios from 'axios';
+import { colour } from '../../Config';
+
+export default class MinecraftServerStatusFun extends Command {
+ public constructor() {
+ super('minecraftserverstatus', {
+ aliases: ['minecraftserverstatus', 'mcss'],
+ category: 'fun',
+ description: {
+ content: 'Check the status of a specified Minecraft server.',
+ usage: '',
+ examples: [
+ ''
+ ]
+ },
+ ratelimit: 3,
+ args: [
+ {
+ id: "ip",
+ prompt: {
+ start: "What is the IP of the server?",
+ optional: false
+ }
+ },
+ {
+ id: "port",
+ prompt: {
+ start: "What is the port of the server?",
+ optional: true
+ }
+ }
+ ]
+ });
+ }
+
+ public async exec(msg: Message, { ip, port }): Promise<Message> {
+ const response = (
+ await Axios(`https://mcapi.us/server/status?ip=${ip}&port=${port}`).catch(err => {
+ console.error(err);
+ return msg.reply('Woops, there was an error with the (https://mcapi.us) API.');
+ })
+ //@ts-ignore
+ ).data;
+
+ if (response.status !== "success") {
+ return msg.reply('Woops, there was an error with the (https://mcapi.us) API.');
+ }
+
+ // https://github.com/discordjs/discord.js/issues/2175#issuecomment-538948474
+
+ let embed = this.client.util.embed()
+ .setTitle(ip)
+ .setTimestamp(response.last_updated)
+ .setColor(colour)
+ .setThumbnail(`https://eu.mc-api.net/v3/server/favicon/${ip}${port ? ':' : ''}`)
+
+ if (response.online) {
+ embed.addField("Server Status", "Currently online.", true);
+ embed.addField("Version", response.server.name, true);
+ embed.addField("Members", `${response.players.now}/${response.players.max}`, true);
+ embed.addField("MOTD", `\`\`\`${response.motd}\`\`\``, true);
+ } else if (response.last_online) {
+ embed.addField("Server Status", `Offline. Last seen ${new Date(response.last_online)}`, true);
+ } else {
+ embed.addField("Server Status", "Offline. Never seen online before.", true);
+ }
+ return msg.channel.send(embed);
+ }
+} \ No newline at end of file
diff --git a/server/src/commands/owner/ServerList.ts b/server/src/commands/owner/ServerList.ts
new file mode 100644
index 0000000..18c618f
--- /dev/null
+++ b/server/src/commands/owner/ServerList.ts
@@ -0,0 +1,30 @@
+import { Command } from 'discord-akairo';
+import { Message } from 'discord.js';
+
+export default class ServerListOwner extends Command {
+ public constructor() {
+ super('serverlist', {
+ aliases: ['serverlist', 'server-list'],
+ category: 'owner',
+ description: {
+ content: 'Check what servers the bot is in.',
+ usage: '',
+ examples: [
+ ''
+ ]
+ },
+ ratelimit: 3,
+ ownerOnly: true
+ });
+ }
+
+ public exec(msg: Message): Promise<Message> {
+ const list = this.client.guilds.cache.map(g => {
+ const servers = g.name;
+ return `- **${servers}:** ${g.id} - ${g.owner?.user.tag} - ${g.memberCount}`;
+ });
+
+ const text = `Total: ${this.client.guilds.cache.size}\n\n### Servers\n\n${list.join("\n")}`;
+ return msg.author.send({ files: [{ attachment: Buffer.from(text), name: "ServerList.txt" }] });
+ }
+} \ No newline at end of file
diff --git a/server/src/listeners/client/message.ts b/server/src/listeners/client/message.ts
index 92c82dc..06ae7b2 100644
--- a/server/src/listeners/client/message.ts
+++ b/server/src/listeners/client/message.ts
@@ -58,7 +58,7 @@ export default class MessageListener extends Listener {
|| msg.content.toLowerCase().includes('neonazi')
) msg.delete();
- if (msg.content.toLowerCase().includes("duck") {
+ if (msg.content.toLowerCase().includes("duck")) {
msg.react("729560925165846530");
}
}