From d72dd989f979070ee79bc45a8c15e40805103a64 Mon Sep 17 00:00:00 2001 From: Neko Life Date: Sun, 27 Jun 2021 22:14:19 +0900 Subject: [PATCH] more image commands => --- cmds/image/baka.js | 22 ++++++++++++++++++++++ cmds/image/cry.js | 22 ++++++++++++++++++++++ cmds/image/dance.js | 22 ++++++++++++++++++++++ cmds/image/laugh.js | 22 ++++++++++++++++++++++ cmds/image/smile.js | 22 ++++++++++++++++++++++ cmds/image/smug.js | 22 ++++++++++++++++++++++ cmds/image/wave.js | 14 ++++++++------ resources/functions.js | 2 +- resources/getColor.js | 6 ++++-- resources/tCmds/convo.js | 8 ++++---- 10 files changed, 149 insertions(+), 13 deletions(-) create mode 100644 cmds/image/baka.js create mode 100644 cmds/image/cry.js create mode 100644 cmds/image/dance.js create mode 100644 cmds/image/laugh.js create mode 100644 cmds/image/smile.js create mode 100644 cmds/image/smug.js diff --git a/cmds/image/baka.js b/cmds/image/baka.js new file mode 100644 index 0000000..1ff89ab --- /dev/null +++ b/cmds/image/baka.js @@ -0,0 +1,22 @@ +'use strict'; + +const commando = require("@iceprod/discord.js-commando"); +const { trySend, defaultImageEmbed } = require("../../resources/functions"); +const { default: fetchNeko } = require("nekos-best.js"); + +module.exports = class baka extends commando.Command { + constructor(client) { + super(client, { + name: "baka", + memberName: "baka", + group: "image", + description: "Say \"baka\" :/" + }); + } + async run(msg) { + const title = `${msg.guild ? msg.member.displayName : msg.author.username} is getting dere-dere~ =>`; + const image = await fetchNeko("baka"); + const emb = defaultImageEmbed(msg, image, title); + return trySend(this.client, msg, emb); + } +}; \ No newline at end of file diff --git a/cmds/image/cry.js b/cmds/image/cry.js new file mode 100644 index 0000000..73c6726 --- /dev/null +++ b/cmds/image/cry.js @@ -0,0 +1,22 @@ +'use strict'; + +const commando = require("@iceprod/discord.js-commando"); +const { trySend, defaultImageEmbed } = require("../../resources/functions"); +const { default: fetchNeko } = require("nekos-best.js"); + +module.exports = class cry extends commando.Command { + constructor(client) { + super(client, { + name: "cry", + memberName: "cry", + group: "image", + description: "Are you sad? :(" + }); + } + async run(msg) { + const title = `${msg.guild ? msg.member.displayName : msg.author.username} is crying :<`; + const image = await fetchNeko("cry"); + const emb = defaultImageEmbed(msg, image, title); + return trySend(this.client, msg, emb); + } +}; \ No newline at end of file diff --git a/cmds/image/dance.js b/cmds/image/dance.js new file mode 100644 index 0000000..b120076 --- /dev/null +++ b/cmds/image/dance.js @@ -0,0 +1,22 @@ +'use strict'; + +const commando = require("@iceprod/discord.js-commando"); +const { trySend, defaultImageEmbed } = require("../../resources/functions"); +const { default: fetchNeko } = require("nekos-best.js"); + +module.exports = class dance extends commando.Command { + constructor(client) { + super(client, { + name: "dance", + memberName: "dance", + group: "image", + description: "Let's dance =]" + }); + } + async run(msg) { + const title = `${msg.guild ? msg.member.displayName : msg.author.username} is dancin :>`; + const image = await fetchNeko("dance"); + const emb = defaultImageEmbed(msg, image, title); + return trySend(this.client, msg, emb); + } +}; \ No newline at end of file diff --git a/cmds/image/laugh.js b/cmds/image/laugh.js new file mode 100644 index 0000000..5ee8f3e --- /dev/null +++ b/cmds/image/laugh.js @@ -0,0 +1,22 @@ +'use strict'; + +const commando = require("@iceprod/discord.js-commando"); +const { trySend, defaultImageEmbed } = require("../../resources/functions"); +const { default: fetchNeko } = require("nekos-best.js"); + +module.exports = class laugh extends commando.Command { + constructor(client) { + super(client, { + name: "laugh", + memberName: "laugh", + group: "image", + description: "Show your laugh :D" + }); + } + async run(msg) { + const title = `${msg.guild ? msg.member.displayName : msg.author.username} is laughin XD`; + const image = await fetchNeko("laugh"); + const emb = defaultImageEmbed(msg, image, title); + return trySend(this.client, msg, emb); + } +}; \ No newline at end of file diff --git a/cmds/image/smile.js b/cmds/image/smile.js new file mode 100644 index 0000000..f2b7e4e --- /dev/null +++ b/cmds/image/smile.js @@ -0,0 +1,22 @@ +'use strict'; + +const commando = require("@iceprod/discord.js-commando"); +const { trySend, defaultImageEmbed } = require("../../resources/functions"); +const { default: fetchNeko } = require("nekos-best.js"); + +module.exports = class smile extends commando.Command { + constructor(client) { + super(client, { + name: "smile", + memberName: "smile", + group: "image", + description: "Show your smile <3" + }); + } + async run(msg) { + const title = `${msg.guild ? msg.member.displayName : msg.author.username} is smilin :D`; + const image = await fetchNeko("smile"); + const emb = defaultImageEmbed(msg, image, title); + return trySend(this.client, msg, emb); + } +}; \ No newline at end of file diff --git a/cmds/image/smug.js b/cmds/image/smug.js new file mode 100644 index 0000000..9739a72 --- /dev/null +++ b/cmds/image/smug.js @@ -0,0 +1,22 @@ +'use strict'; + +const commando = require("@iceprod/discord.js-commando"); +const { trySend, defaultImageEmbed } = require("../../resources/functions"); +const { default: fetchNeko } = require("nekos-best.js"); + +module.exports = class smug extends commando.Command { + constructor(client) { + super(client, { + name: "smug", + memberName: "smug", + group: "image", + description: "Show your smug :]" + }); + } + async run(msg) { + const title = `${msg.guild ? msg.member.displayName : msg.author.username} got a smug face >:]`; + const image = await fetchNeko("smug"); + const emb = defaultImageEmbed(msg, image, title); + return trySend(this.client, msg, emb); + } +}; \ No newline at end of file diff --git a/cmds/image/wave.js b/cmds/image/wave.js index f5b4a47..ab1d844 100644 --- a/cmds/image/wave.js +++ b/cmds/image/wave.js @@ -1,8 +1,8 @@ 'use strict'; const commando = require("@iceprod/discord.js-commando"); -const { trySend } = require("../../resources/functions"); -const interactEmbed = require("./interactEmbed"); +const { trySend, defaultImageEmbed } = require("../../resources/functions"); +const { default: fetchNeko } = require("nekos-best.js"); module.exports = class wave extends commando.Command { constructor(client) { @@ -10,11 +10,13 @@ module.exports = class wave extends commando.Command { name: "wave", memberName: "wave", group: "image", - description: "Wave everyone!", - guildOnly: true + description: "Wave to you friends!" }); } - async run(msg, arg) { - return trySend(this.client, msg, await interactEmbed(msg, arg, "wave", ":D")); + async run(msg) { + const title = `${msg.guild ? msg.member.displayName : msg.author.username} is waving :)`; + const image = await fetchNeko("wave"); + const emb = defaultImageEmbed(msg, image, title); + return trySend(this.client, msg, emb); } }; \ No newline at end of file diff --git a/resources/functions.js b/resources/functions.js index eb6ce79..2d77148 100644 --- a/resources/functions.js +++ b/resources/functions.js @@ -19,7 +19,7 @@ const { CommandoMessage, CommandoClient } = require('@iceprod/discord.js-command async function errLog(theError, msg, client, sendTheError, errorMessage, notify) { if (!client && msg) client = msg.client; if (!(theError instanceof Error) || !client) return console.error("[ERRLOG] Not error instance or no required param:", theError); - let [ret, logThis, inLogChannel, sendErr] = [null, '', '', '']; + let [ret, logThis, inLogChannel, sendErr] = [undefined, '', '', '']; if (msg instanceof Message) { client.emit("commandError", msg.command, theError, msg); logThis = `\`${msg.command?.name}\` (${msg.id}) ${msg.url} in ${msg.guild ? `**${msg.channel.name}** (${msg.channel.id}) of **${msg.guild.name}** (${msg.guild.id})` : `**DM**`} ran by **${msg.author.tag}** (${msg.author.id}) \n\n`; diff --git a/resources/getColor.js b/resources/getColor.js index 997b171..3ce2a08 100644 --- a/resources/getColor.js +++ b/resources/getColor.js @@ -14,7 +14,7 @@ module.exports = function getColor(name) { return name; } } - switch(name) { + switch (name) { case 'rosy brown': return 12357519; case 'magenta': @@ -56,7 +56,9 @@ module.exports = function getColor(name) { if (name.startsWith("#")) name = name.slice(1); return name; } else { - return parseInt(name, 10); + const n = parseInt(name, 10); + if (n >= 16777215) return 16777214; + return n; } } } diff --git a/resources/tCmds/convo.js b/resources/tCmds/convo.js index ad823ef..ea46b6b 100644 --- a/resources/tCmds/convo.js +++ b/resources/tCmds/convo.js @@ -74,14 +74,13 @@ module.exports = { } if (u === "r") { if (C.length > 0) { - for (const a of C) console.log("Resuming session:", a.guild.name, a.guild.id, a.name, a.id); + for (let i = 0; i < C.length; i++) console.log("Resuming session:", C[i].guild.name, C[i].guild.id, i + ":", C[i].name, C[i].id); return client.convo = true; } else return console.log("No previous session"); } if (u === "q") { if (C.length > 0 && client.convo) { - console.log("Ending sessions:"); - for (const a of C) console.log(a.guild.name, a.guild.id, a.name, a.id); + for (let i = 0; i < C.length; i++) console.log("Ending session:", C[i].guild.name, C[i].guild.id, i + ":", C[i].name, C[i].id); client.convo = false; } return console.log("Ended"); @@ -100,7 +99,8 @@ module.exports = { for (let i = 0; i < C.length; i++) console.log(C[i].guild.name, C[i].guild.id, i + ":", C[i].name, C[i].id); } else if (C[num]) return C[num].send(emoteMessage(client, sl ? arg.slice(num?.toString().length).trim() : arg)).catch(console.error); else { console.log('No session. Available sessions:'); - for (const a of C) console.log(a.guild.name, a.guild.id, a.name, a.id); + for (let i = 0; i < C.length; i++) console.log(C[i].guild.name, C[i].guild.id, i + ":", C[i].name, C[i].id); + return; }; return client.convo = true; }