diff --git a/mapvote.js b/mapvote.js index 2b5c7e1..b9c3d74 100644 --- a/mapvote.js +++ b/mapvote.js @@ -1,6 +1,7 @@ //Plugin by MaskedMonkeyMan import BasePlugin from "./base-plugin.js"; +import DiscordBasePlugin from './discord-base-plugin.js'; import fs from "fs"; import { Layers } from "../layers/index.js" @@ -79,7 +80,19 @@ export default class MapVote extends BasePlugin { required: false, description: 'random layer list will not include the blacklisted layers or levels. (acceptable formats: Gorodok/Gorodok_RAAS/Gorodok_AAS_v1)', default: [] - } + }, + logToDiscord: { + required: false, + description: 'Log votes to Discord', + default: false + }, + ...DiscordBasePlugin.optionsSpecification, + channelID: { + required: false, + description: 'The ID of the channel to log votes to.', + default: '', + example: '667741905228136459' + } }; } @@ -510,7 +523,9 @@ export default class MapVote extends BasePlugin { nominationStrings.push(formatChoice(choice, this.nominations[ choice ].replace(/\_/gi, ' ').replace(/\sv\d{1,2}/gi, '') + ' ' + this.factionStrings[ choice ], this.tallies[ choice ], this.firstBroadcast)); } await this.broadcast(nominationStrings.join("\n")); - + + if (this.firstBroadcast) + await this.logVoteToDiscord(nominationStrings.join("\n")) this.firstBroadcast = false; } //const winners = this.currentWinners; @@ -584,4 +599,20 @@ export default class MapVote extends BasePlugin { return ties.map(i => this.nominations[ i ]); } + + async logVoteToDiscord(message) { + if (!this.options.logToDiscord) return + await this.sendDiscordMessage({ + embed: { + title: 'Vote Started', + color: 16761867, + fields: [ + { + name: 'Options:', + value: `${message}` + } + ] + } + }); + } }