|
@@ -6,6 +6,7 @@ import { getRepository } from "typeorm";
|
|
|
import { Contest } from "@db/entity/Contest";
|
|
|
import { isNumber } from "util";
|
|
|
import emoji_regex from "emoji-regex";
|
|
|
+import { client } from "../client";
|
|
|
|
|
|
|
|
|
const CHANNEL_ID_PATTERN = /<#(\d+)>/;
|
|
@@ -48,9 +49,6 @@ function parseDuration(duration: string) : number | undefined {
|
|
|
return undefined;
|
|
|
|
|
|
let num = match[1];
|
|
|
- if(!isNumber(num))
|
|
|
- return undefined;
|
|
|
-
|
|
|
let unit = match[2];
|
|
|
|
|
|
return +num * DURATION_MULTIPLIERS[unit];
|
|
@@ -83,7 +81,8 @@ async function createContest(msg: Message, info: ContestCreationOptions) {
|
|
|
channel: info.in,
|
|
|
startDate: new Date(),
|
|
|
endDate: new Date(Date.now() + dur),
|
|
|
- announceWinners: info.announce_winners
|
|
|
+ announceWinners: info.announce_winners,
|
|
|
+ voteReaction: info.vote_reaction
|
|
|
});
|
|
|
|
|
|
await repo.save(contest);
|
|
@@ -95,7 +94,8 @@ export default <ICommand>{
|
|
|
{
|
|
|
pattern: "create contest",
|
|
|
action: async (m, contents) => {
|
|
|
- let message = contents.substr("create contest".length);
|
|
|
+ let message = m.content.trim().substr(client.user.toString().length).trim().substr("create contest".length).trim();
|
|
|
+ // let message = contents.substr("create contest".length);
|
|
|
let contestData : ContestCreationOptions = { ...CONTEST_DEFAULTS, ...yaml.parse(message) };
|
|
|
|
|
|
if(!contestData.in)
|