mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 12:36:35 +00:00
Try review and deprecate approve/reject in favor of !review
This commit is contained in:
parent
05e4eb4d59
commit
53c5473da8
3 changed files with 12 additions and 76 deletions
|
|
@ -1,34 +0,0 @@
|
|||
const { approve, getStatus } = require("../../data/skins");
|
||||
const Utils = require("../utils");
|
||||
const { TWEET_BOT_CHANNEL_ID } = require("../../config");
|
||||
|
||||
async function handler(message, args) {
|
||||
const [md5] = args;
|
||||
const status = await getStatus(md5);
|
||||
if (status !== "UNREVIEWED") {
|
||||
await message.channel.send(`This skin has already been reviewed.`);
|
||||
return;
|
||||
}
|
||||
await approve(md5);
|
||||
const tweetBotChannel = message.client.channels.get(TWEET_BOT_CHANNEL_ID);
|
||||
let filename = null;
|
||||
await Utils.postSkin({
|
||||
md5,
|
||||
title: (f) => {
|
||||
// Hack to get access to the file name
|
||||
filename = f;
|
||||
return `Approve: ${f}`;
|
||||
},
|
||||
dest: tweetBotChannel,
|
||||
});
|
||||
await tweetBotChannel.send(
|
||||
`${filename} was approved by ${message.author.username}`
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
command: "approve",
|
||||
handler,
|
||||
usage: "<md5-hash>",
|
||||
description: "Approve a given skin to be Tweeted by the Twitter bot",
|
||||
};
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
const { reject, getStatus } = require("../../data/skins");
|
||||
const Utils = require("../utils");
|
||||
const { TWEET_BOT_CHANNEL_ID } = require("../../config");
|
||||
|
||||
async function handler(message, args) {
|
||||
const [md5] = args;
|
||||
const status = await getStatus(md5);
|
||||
if (status !== "UNREVIEWED") {
|
||||
await message.channel.send(`This skin has already been reviewed.`);
|
||||
return;
|
||||
}
|
||||
await reject(md5);
|
||||
const tweetBotChannel = message.client.channels.get(TWEET_BOT_CHANNEL_ID);
|
||||
let filename = null;
|
||||
await Utils.postSkin({
|
||||
md5,
|
||||
title: (f) => {
|
||||
// Hack to get access to the file name
|
||||
filename = f;
|
||||
return `Rejected: ${f}`;
|
||||
},
|
||||
dest: tweetBotChannel,
|
||||
});
|
||||
await tweetBotChannel.send(
|
||||
`${filename} was rejected by ${message.author.username}`
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
command: "reject",
|
||||
handler,
|
||||
usage: "<md5-hash>",
|
||||
description: "Reject a given skin from being Tweeted by the Twitter bot",
|
||||
};
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
const Skins = require("../../data/skins");
|
||||
const Utils = require("../utils");
|
||||
import * as Skins from "../../data/skins";
|
||||
import * as Utils from "../utils";
|
||||
import { Message } from "discord.js";
|
||||
|
||||
async function reviewSkin(message) {
|
||||
async function reviewSkin(message: Message): Promise<void> {
|
||||
const skin = await Skins.getSkinToReview();
|
||||
if (skin == null) {
|
||||
throw new Error("No skins to review");
|
||||
|
|
@ -14,15 +15,16 @@ async function reviewSkin(message) {
|
|||
});
|
||||
}
|
||||
|
||||
async function handler(message, args) {
|
||||
let count = args[0] || 1;
|
||||
async function handler(message: Message, args: [string]) {
|
||||
let count = Number(args[0] || 1);
|
||||
if (count > 50) {
|
||||
await message.channel.send(`You can only review up to ${count} skins at a time.`);
|
||||
await message.channel.send(`Going to show ${count} skins to review`);
|
||||
await message.channel.send(
|
||||
`You can only review up to ${count} skins at a time.`
|
||||
);
|
||||
count = 50;
|
||||
}
|
||||
await message.channel.send(`Going to show ${count} skins to review.`);
|
||||
let i = Number(count);
|
||||
let i = count;
|
||||
while (i--) {
|
||||
await reviewSkin(message);
|
||||
}
|
||||
|
|
@ -31,6 +33,8 @@ async function handler(message, args) {
|
|||
await message.channel.send(
|
||||
`Done reviewing ${count} skins. There are now ${tweetableCount} Tweetable skins. Thanks!`
|
||||
);
|
||||
} else {
|
||||
await message.channel.send(`Thanks!`);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue