init commit

This commit is contained in:
zino
2021-02-16 23:07:41 +01:00
parent ec3fc78e0f
commit 12b4ef5db4
5000 changed files with 2596132 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* This module is to handles the random game.
*/
(function() {
var responseCount = 0,
lastRandom = 0;
/**
* @function loadResponses
*/
function loadResponses() {
for (var i = 1; $.lang.exists('randomcommand.' + i); i++) {
responseCount++;
}
}
/**
* @event discordChannelCommand
*/
$.bind('discordChannelCommand', function(event) {
var channel = event.getDiscordChannel(),
command = event.getCommand();
/**
* @discordcommandpath random - Will display something really random.
*/
if (command.equalsIgnoreCase('random')) {
var random;
do {
random = $.randRange(1, responseCount);
} while (random == lastRandom);
$.discord.say(channel, $.tags(event, $.lang.get('randomcommand.' + random), false));
lastRandom = random;
}
});
/**
* @event initReady
*/
$.bind('initReady', function() {
$.discord.registerCommand('./discord/games/random.js', 'random', 0);
if (responseCount === 0) {
loadResponses();
}
});
})();