From 7e7167796f6618ab14c78ef2d3a348fcab3ecfd7 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Tue, 9 Aug 2022 12:32:03 +0100 Subject: [PATCH 1/4] Add say command (#174) Co-authored-by: Ethan Lane Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/174 --- .env.template | 4 ++-- src/commands/say.ts | 26 ++++++++++++++++++++++++++ src/registry.ts | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/commands/say.ts diff --git a/.env.template b/.env.template index ab57e01..88ad8df 100644 --- a/.env.template +++ b/.env.template @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=3.0.4 +BOT_VER=3.1 BOT_AUTHOR=Vylpes -BOT_DATE=06 Jul 2022 +BOT_DATE=08 Aug 2022 BOT_OWNERID=147392775707426816 diff --git a/src/commands/say.ts b/src/commands/say.ts new file mode 100644 index 0000000..433b2b8 --- /dev/null +++ b/src/commands/say.ts @@ -0,0 +1,26 @@ +import { ICommandContext } from "../contracts/ICommandContext"; +import ErrorEmbed from "../helpers/embeds/ErrorEmbed"; +import { Command } from "../type/command"; + +export default class Say extends Command { + constructor() { + super(); + super.Category = "Misc"; + super.Roles = [ + "moderator" + ]; + } + + public override async execute(context: ICommandContext) { + const input = context.args.join(" "); + + if (input.length == 0) { + const errorEmbed = new ErrorEmbed(context, "You must supply a message."); + + await errorEmbed.SendToCurrentChannel(); + return; + } + + context.message.channel.send(input); + } +} \ No newline at end of file diff --git a/src/registry.ts b/src/registry.ts index 183bac2..4fa68f7 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -14,6 +14,7 @@ import Mute from "./commands/mute"; import Poll from "./commands/poll"; import Role from "./commands/role"; import Rules from "./commands/rules"; +import Say from "./commands/say"; import Setup from "./commands/setup"; import Unmute from "./commands/unmute"; import Warn from "./commands/warn"; @@ -46,6 +47,7 @@ export default class Registry { CoreClient.RegisterCommand("unmute", new Unmute()); CoreClient.RegisterCommand("warn", new Warn()); CoreClient.RegisterCommand("setup", new Setup()); + CoreClient.RegisterCommand("say", new Say()); // Exclusive Commands: MankBot CoreClient.RegisterCommand("lobby", new Lobby(), "501231711271780357"); -- 2.43.4 From 7c90b2ff88548f03b4199ef85de20271cf7ea03a Mon Sep 17 00:00:00 2001 From: Vylpes Date: Sat, 13 Aug 2022 14:51:40 +0100 Subject: [PATCH 2/4] Add repo and funding link to about message (#176) Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/176 --- .env.template | 3 +++ package.json | 8 ++++---- src/commands/about.ts | 23 +++++++++++++++++++---- src/helpers/embeds/PublicEmbed.ts | 6 +++--- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.env.template b/.env.template index 88ad8df..5862d9c 100644 --- a/.env.template +++ b/.env.template @@ -11,3 +11,6 @@ BOT_VER=3.1 BOT_AUTHOR=Vylpes BOT_DATE=08 Aug 2022 BOT_OWNERID=147392775707426816 + +ABOUT_FUNDING= +ABOUT_REPO= diff --git a/package.json b/package.json index b45562f..aa06b2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vylbot-app", - "version": "3.0.4", + "version": "3.1.0", "description": "A discord bot made for Vylpes' Den", "main": "./dist/vylbot", "typings": "./dist", @@ -13,12 +13,12 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Vylpes/vylbot-app.git" + "url": "https://gitea.vylpes.xyz/rabbitlabs/vylbot-app" }, "author": "Vylpes", "license": "MIT", - "bugs": "https://github.com/Vylpes/vylbot-app/issues", - "homepage": "https://github.com/Vylpes/vylbot-app", + "bugs": "https://gitea.vylpes.xyz/rabbitlabs/vylbot-app/issues", + "homepage": "https://gitea.vylpes.xyz/rabbitlabs/vylbot-app", "dependencies": { "@types/jest": "^27.0.3", "@types/uuid": "^8.3.4", diff --git a/src/commands/about.ts b/src/commands/about.ts index 4246113..a5f62f4 100644 --- a/src/commands/about.ts +++ b/src/commands/about.ts @@ -1,3 +1,5 @@ +import { Emoji, MessageActionRow, MessageButton } from "discord.js"; +import { MessageButtonStyles } from "discord.js/typings/enums"; import { ICommandContext } from "../contracts/ICommandContext"; import PublicEmbed from "../helpers/embeds/PublicEmbed"; import { Command } from "../type/command"; @@ -9,11 +11,24 @@ export default class About extends Command { } public override async execute(context: ICommandContext) { + const fundingLink = process.env.ABOUT_FUNDING; + const repoLink = process.env.ABOUT_REPO; + const embed = new PublicEmbed(context, "About", "") - .addField("Version", process.env.BOT_VER!) - .addField("Author", process.env.BOT_AUTHOR!) - .addField("Date", process.env.BOT_DATE!); + .addField("Version", process.env.BOT_VER!, true) + .addField("Author", process.env.BOT_AUTHOR!, true) + .addField("Date", process.env.BOT_DATE!, true); + + const row = new MessageActionRow(); + + if (repoLink) { + row.addComponents(new MessageButton().setURL(repoLink).setLabel("Repo").setStyle(MessageButtonStyles.LINK)); + } + + if (fundingLink) { + row.addComponents(new MessageButton().setURL(fundingLink).setLabel("Funding").setStyle(MessageButtonStyles.LINK)); + } - await embed.SendToCurrentChannel(); + await embed.SendToCurrentChannel({ components: [row] }); } } \ No newline at end of file diff --git a/src/helpers/embeds/PublicEmbed.ts b/src/helpers/embeds/PublicEmbed.ts index 84be5c9..059826b 100644 --- a/src/helpers/embeds/PublicEmbed.ts +++ b/src/helpers/embeds/PublicEmbed.ts @@ -1,4 +1,4 @@ -import { MessageEmbed, Permissions, TextChannel } from "discord.js"; +import { MessageEmbed, MessageOptions, Permissions, TextChannel } from "discord.js"; import { ICommandContext } from "../../contracts/ICommandContext"; export default class PublicEmbed extends MessageEmbed { @@ -20,7 +20,7 @@ export default class PublicEmbed extends MessageEmbed { } // Send methods - public async SendToCurrentChannel() { + public async SendToCurrentChannel(options?: MessageOptions) { const channel = this.context.message.channel as TextChannel; const botMember = await this.context.message.guild?.members.fetch({ user: this.context.message.client.user! }); @@ -30,6 +30,6 @@ export default class PublicEmbed extends MessageEmbed { if (!permissions.has(Permissions.FLAGS.SEND_MESSAGES)) return; - this.context.message.channel.send({ embeds: [ this ]}); + this.context.message.channel.send({ embeds: [ this ], ...options}); } } \ No newline at end of file -- 2.43.4 From 3f6379b95e484a3a731f9a0dffb54eefbaf8f0f5 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sun, 14 Aug 2022 13:27:46 +0100 Subject: [PATCH 3/4] Add other subreddits to bunny command --- src/commands/bunny.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/commands/bunny.ts b/src/commands/bunny.ts index 47bafa6..a41e179 100644 --- a/src/commands/bunny.ts +++ b/src/commands/bunny.ts @@ -12,13 +12,24 @@ export default class Bunny extends Command { } public override async execute(context: ICommandContext) { - const result = await randomBunny('rabbits', 'hot'); + const subreddits = [ + 'rabbits', + 'bunnieswithhats', + 'buncomfortable', + 'bunnytongues', + 'dutchbunnymafia', + ]; + + const random = Math.floor(Math.random() * subreddits.length); + const selectedSubreddit = subreddits[random]; + + const result = await randomBunny(selectedSubreddit, 'hot'); if (result.IsSuccess) { const embed = new PublicEmbed(context, result.Result!.Title, "") .setImage(result.Result!.Url) .setURL(`https://reddit.com${result.Result!.Permalink}`) - .setFooter({ text: `r/Rabbits · ${result.Result!.Ups} upvotes` }); + .setFooter({ text: `r/${selectedSubreddit} · ${result.Result!.Ups} upvotes` }); await embed.SendToCurrentChannel(); } else { -- 2.43.4 From e432b403b587ef627d3de0cef14e8713d330321f Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 20 Aug 2022 15:50:01 +0100 Subject: [PATCH 4/4] Fix changes requested --- .env.template | 2 +- package.json | 9 ++++++--- src/commands/about.ts | 12 ++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.env.template b/.env.template index 5862d9c..89d6897 100644 --- a/.env.template +++ b/.env.template @@ -9,7 +9,7 @@ BOT_TOKEN= BOT_VER=3.1 BOT_AUTHOR=Vylpes -BOT_DATE=08 Aug 2022 +BOT_DATE=20 Aug 2022 BOT_OWNERID=147392775707426816 ABOUT_FUNDING= diff --git a/package.json b/package.json index aa06b2d..b7cfc34 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,15 @@ }, "repository": { "type": "git", - "url": "https://gitea.vylpes.xyz/rabbitlabs/vylbot-app" + "url": "https://github.com/Vylpes/vylbot-app" }, "author": "Vylpes", "license": "MIT", - "bugs": "https://gitea.vylpes.xyz/rabbitlabs/vylbot-app/issues", - "homepage": "https://gitea.vylpes.xyz/rabbitlabs/vylbot-app", + "bugs": { + "url": "https://github.com/Vylpes/vylbot-app/issues", + "email": "helpdesk@vylpes.com" + }, + "homepage": "https://github.com/Vylpes/vylbot-app", "dependencies": { "@types/jest": "^27.0.3", "@types/uuid": "^8.3.4", diff --git a/src/commands/about.ts b/src/commands/about.ts index a5f62f4..1391da9 100644 --- a/src/commands/about.ts +++ b/src/commands/about.ts @@ -22,11 +22,19 @@ export default class About extends Command { const row = new MessageActionRow(); if (repoLink) { - row.addComponents(new MessageButton().setURL(repoLink).setLabel("Repo").setStyle(MessageButtonStyles.LINK)); + row.addComponents( + new MessageButton() + .setURL(repoLink) + .setLabel("Repo") + .setStyle(MessageButtonStyles.LINK)); } if (fundingLink) { - row.addComponents(new MessageButton().setURL(fundingLink).setLabel("Funding").setStyle(MessageButtonStyles.LINK)); + row.addComponents( + new MessageButton() + .setURL(fundingLink) + .setLabel("Funding") + .setStyle(MessageButtonStyles.LINK)); } await embed.SendToCurrentChannel({ components: [row] }); -- 2.43.4