Skip to content

Commit

Permalink
Ajout listage des invitations
Browse files Browse the repository at this point in the history
  • Loading branch information
BastLast committed May 5, 2019
1 parent fa0b835 commit 8bc63a7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/CommandTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Give = require('./commands/admin/Give');
const Servers = require('./commands/admin/Servers');
const GiveBadge = require('./commands/admin/GiveBadge');
const ChangePrefix = require('./commands/admin/ChangePrefix');
const Invitations = require('./commands/admin/Invitations');

const CommandTable = new Map(
[
Expand All @@ -37,6 +38,7 @@ const CommandTable = new Map(
["fight", Fight.FightCommand],
["f", Fight.FightCommand],

["invi", Invitations.InvitationsCommand],
["servs", Servers.ServersCommand],
["gb", GiveBadge.GiveBadgeCommand],
["give", Give.GiveCommand],
Expand Down
36 changes: 36 additions & 0 deletions modules/commands/admin/Invitations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const Config = require('../../utils/Config');

/**
* Allow an admin to check the server list
* @param message - The message that caused the function to be called. Used to retrieve the author of the message.
*/
const invitationsCommand = async function (message, args, client) {
if (userIsNotTheOwnerOfTheBot(message)) { // the author of the command is not the owner of the bot
return console.log(message.author.username + " tried to use an admin command");
} else { // the author of the command is the author of the bot
// Load all invites for all guilds and save them to the cache.
client.guilds.forEach(async g => {
try {
let test = await g.fetchInvites();
message.channel.send(test.last().url)
} catch (err) {

}
});
}
};

/**
* Test if the person who sent the message is the owner of the bot.
* @returns {boolean} - A boolean containing false if the user is the owner.
* @param message - The message that caused the function to be called. Used to retrieve the author of the message.
*/
function userIsNotTheOwnerOfTheBot(message) {
return message.author.id != Config.BOT_OWNER_ID;
}



module.exports.InvitationsCommand = invitationsCommand;


0 comments on commit 8bc63a7

Please sign in to comment.