mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-24 01:23:52 -06:00
Merge pull request #4 from Coolisbetter/logToDiscord
add: log to Discord the start of voting
This commit is contained in:
commit
be0463988c
31
mapvote.js
31
mapvote.js
@ -1,6 +1,7 @@
|
|||||||
//Plugin reworked by JetDave, original version by MaskedMonkeyMan
|
//Plugin reworked by JetDave, original version by MaskedMonkeyMan
|
||||||
|
|
||||||
import BasePlugin from "./base-plugin.js";
|
import BasePlugin from "./base-plugin.js";
|
||||||
|
import DiscordBasePlugin from './discord-base-plugin.js';
|
||||||
|
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { Layers } from "../layers/index.js"
|
import { Layers } from "../layers/index.js"
|
||||||
@ -94,6 +95,18 @@ export default class MapVote extends BasePlugin {
|
|||||||
required: false,
|
required: false,
|
||||||
description: 'Message that is sent as broadcast to announce a vote',
|
description: 'Message that is sent as broadcast to announce a vote',
|
||||||
default: "✯ MAPVOTE ✯ Vote for the next map by writing in chat the corresponding number!"
|
default: "✯ MAPVOTE ✯ Vote for the next map by writing in chat the corresponding number!"
|
||||||
|
},
|
||||||
|
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'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -591,6 +604,8 @@ export default class MapVote extends BasePlugin {
|
|||||||
if (this.nominations[ 0 ]) nominationStrings.push(formatChoice(0, this.nominations[ 0 ], this.tallies[ 0 ], (this.options.hideVotesCount || this.firstBroadcast)))
|
if (this.nominations[ 0 ]) nominationStrings.push(formatChoice(0, this.nominations[ 0 ], this.tallies[ 0 ], (this.options.hideVotesCount || this.firstBroadcast)))
|
||||||
await this.broadcast(nominationStrings.join("\n"));
|
await this.broadcast(nominationStrings.join("\n"));
|
||||||
|
|
||||||
|
if (this.firstBroadcast)
|
||||||
|
await this.logVoteToDiscord(nominationStrings.join("\n"))
|
||||||
this.firstBroadcast = false;
|
this.firstBroadcast = false;
|
||||||
}
|
}
|
||||||
//const winners = this.currentWinners;
|
//const winners = this.currentWinners;
|
||||||
@ -664,4 +679,20 @@ export default class MapVote extends BasePlugin {
|
|||||||
|
|
||||||
return ties.map(i => this.nominations[ i ]);
|
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}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user