Feature/vba 52 (#175)

* Add say command (#174)

Co-authored-by: Ethan Lane <ethan@vylpes.com>
Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/174

* Add repo and funding link to about message (#176)

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/176

* Add other subreddits to bunny command

* Fix changes requested
This commit is contained in:
Vylpes 2022-09-05 18:07:32 +01:00 committed by GitHub
parent 4d01f0b34a
commit 2da5e1aa75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 13 deletions

View file

@ -9,5 +9,8 @@
BOT_TOKEN= BOT_TOKEN=
BOT_VER=3.1 BOT_VER=3.1
BOT_AUTHOR=Vylpes BOT_AUTHOR=Vylpes
BOT_DATE=08 Aug 2022 BOT_DATE=04 Sep 2022
BOT_OWNERID=147392775707426816 BOT_OWNERID=147392775707426816
ABOUT_FUNDING=
ABOUT_REPO=

View file

@ -1,6 +1,6 @@
{ {
"name": "vylbot-app", "name": "vylbot-app",
"version": "3.0.4", "version": "3.1.0",
"description": "A discord bot made for Vylpes' Den", "description": "A discord bot made for Vylpes' Den",
"main": "./dist/vylbot", "main": "./dist/vylbot",
"typings": "./dist", "typings": "./dist",
@ -13,11 +13,14 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/Vylpes/vylbot-app.git" "url": "https://github.com/Vylpes/vylbot-app"
}, },
"author": "Vylpes", "author": "Vylpes",
"license": "MIT", "license": "MIT",
"bugs": "https://github.com/Vylpes/vylbot-app/issues", "bugs": {
"url": "https://github.com/Vylpes/vylbot-app/issues",
"email": "helpdesk@vylpes.com"
},
"homepage": "https://github.com/Vylpes/vylbot-app", "homepage": "https://github.com/Vylpes/vylbot-app",
"dependencies": { "dependencies": {
"@types/jest": "^27.0.3", "@types/jest": "^27.0.3",

View file

@ -1,3 +1,5 @@
import { Emoji, MessageActionRow, MessageButton } from "discord.js";
import { MessageButtonStyles } from "discord.js/typings/enums";
import { ICommandContext } from "../contracts/ICommandContext"; import { ICommandContext } from "../contracts/ICommandContext";
import PublicEmbed from "../helpers/embeds/PublicEmbed"; import PublicEmbed from "../helpers/embeds/PublicEmbed";
import { Command } from "../type/command"; import { Command } from "../type/command";
@ -9,11 +11,32 @@ export default class About extends Command {
} }
public override async execute(context: ICommandContext) { public override async execute(context: ICommandContext) {
const embed = new PublicEmbed(context, "About", "") const fundingLink = process.env.ABOUT_FUNDING;
.addField("Version", process.env.BOT_VER!) const repoLink = process.env.ABOUT_REPO;
.addField("Author", process.env.BOT_AUTHOR!)
.addField("Date", process.env.BOT_DATE!);
await embed.SendToCurrentChannel(); const embed = new PublicEmbed(context, "About", "")
.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({ components: [row] });
} }
} }

View file

@ -12,13 +12,24 @@ export default class Bunny extends Command {
} }
public override async execute(context: ICommandContext) { 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) { if (result.IsSuccess) {
const embed = new PublicEmbed(context, result.Result!.Title, "") const embed = new PublicEmbed(context, result.Result!.Title, "")
.setImage(result.Result!.Url) .setImage(result.Result!.Url)
.setURL(`https://reddit.com${result.Result!.Permalink}`) .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(); await embed.SendToCurrentChannel();
} else { } else {

View file

@ -1,4 +1,4 @@
import { MessageEmbed, Permissions, TextChannel } from "discord.js"; import { MessageEmbed, MessageOptions, Permissions, TextChannel } from "discord.js";
import { ICommandContext } from "../../contracts/ICommandContext"; import { ICommandContext } from "../../contracts/ICommandContext";
export default class PublicEmbed extends MessageEmbed { export default class PublicEmbed extends MessageEmbed {
@ -20,7 +20,7 @@ export default class PublicEmbed extends MessageEmbed {
} }
// Send methods // Send methods
public async SendToCurrentChannel() { public async SendToCurrentChannel(options?: MessageOptions) {
const channel = this.context.message.channel as TextChannel; const channel = this.context.message.channel as TextChannel;
const botMember = await this.context.message.guild?.members.fetch({ user: this.context.message.client.user! }); 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; if (!permissions.has(Permissions.FLAGS.SEND_MESSAGES)) return;
this.context.message.channel.send({ embeds: [ this ]}); this.context.message.channel.send({ embeds: [ this ], ...options});
} }
} }