Compare commits
2 Commits
7217e968dd
...
52a5c63230
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52a5c63230 | ||
|
|
bd555b17c8 |
83
index.js
83
index.js
@ -94,7 +94,7 @@ client.on("error", (error) => {
|
||||
if (!channel) return console.error("Can't find command channel");
|
||||
client.channels.cache
|
||||
.get(COMMAND_CHANNEL_ID)
|
||||
.send(`error: ${error.message}`)
|
||||
.send(`Error: ${error.message}`)
|
||||
.catch(console.error);
|
||||
});
|
||||
|
||||
@ -131,13 +131,13 @@ client.on("interactionCreate", async (interaction) => {
|
||||
!captain.members.has(interaction.user.id)
|
||||
) {
|
||||
await interaction.reply({
|
||||
content: "must be in picking or captains channel to use this command",
|
||||
content: "Must be in picking or captains channel to use this command",
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
await interaction.reply({
|
||||
content: "checking picking channel...",
|
||||
content: "Checking picking channel...",
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
@ -151,7 +151,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
for (const member of picking.members.values()) {
|
||||
if (member.roles.cache.find((role) => role.name === roleName)) {
|
||||
if (str !== `In picking (${roleName}):`) str += ",";
|
||||
str += " " + member.user.globalName;
|
||||
str += " " + getApplicableName(member);
|
||||
}
|
||||
}
|
||||
if (str === `In picking (${roleName}):`)
|
||||
@ -164,7 +164,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
|
||||
if (interaction.channelId !== COMMAND_CHANNEL_ID) {
|
||||
await interaction.reply({
|
||||
content: "wrong channel, or you lack the required permissions",
|
||||
content: "Wrong channel, or you lack the required permissions",
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
@ -179,7 +179,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
command === "end" ||
|
||||
command === "resetteams"
|
||||
) {
|
||||
await interaction.reply("moving members...");
|
||||
await interaction.reply("Moving members...");
|
||||
|
||||
// get voice channels
|
||||
const blu = interaction.guild.channels.cache.find(
|
||||
@ -204,7 +204,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
if (command !== "resetteams") members = members.concat(addup.members);
|
||||
if (members.size === 0) {
|
||||
return await interaction.followUp(
|
||||
`found no members in ${
|
||||
`Found no members in ${
|
||||
command === "resetteams" ? "blu" : "addup, blu,"
|
||||
} or red`
|
||||
);
|
||||
@ -233,7 +233,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
|
||||
moveAllToAddup().then(() =>
|
||||
interaction.followUp(
|
||||
`moved members in ${
|
||||
`Moved members in ${
|
||||
command === "resetteams" ? "blu" : "addup, blu,"
|
||||
} and red${eCount > 0 ? ` (error moving ${eCount} members)` : ""}`
|
||||
)
|
||||
@ -241,7 +241,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
}
|
||||
|
||||
if (command === "fk" || command === "fatkid") {
|
||||
await interaction.reply("moving fatkids...");
|
||||
await interaction.reply("Moving fatkids...");
|
||||
|
||||
// get voice channels
|
||||
const picking = interaction.guild.channels.cache.find(
|
||||
@ -256,7 +256,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
// get members in voice channel
|
||||
const members = picking.members;
|
||||
if (members.size === 0) {
|
||||
return await interaction.followUp("found no members in picking");
|
||||
return await interaction.followUp("Found no members in picking");
|
||||
}
|
||||
|
||||
let str = "",
|
||||
@ -266,7 +266,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
try {
|
||||
await member.voice.setChannel(fk);
|
||||
if (str.length > 0) str += ", ";
|
||||
str += member.user.globalName;
|
||||
str += getApplicableName(member);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
eCount++;
|
||||
@ -283,7 +283,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
|
||||
logAllFks().then(() =>
|
||||
interaction.followUp(
|
||||
`fatkids: ${str}${
|
||||
`Fatkids: ${str}${
|
||||
eCount > 0 ? ` (error moving ${eCount} members)` : ""
|
||||
}`
|
||||
)
|
||||
@ -291,7 +291,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
}
|
||||
|
||||
if (command === "clear" || command === "bclear") {
|
||||
await interaction.reply("clearing messages...");
|
||||
await interaction.reply("Clearing messages...");
|
||||
let channel = client.channels.cache.get(COMMAND_CHANNEL_ID);
|
||||
if (!channel) return console.error("Can't find command channel");
|
||||
channel.messages
|
||||
@ -307,6 +307,15 @@ client.on("interactionCreate", async (interaction) => {
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* DM commands
|
||||
* - setrank: saves a player's rank
|
||||
* - getrank: prints a player's rank
|
||||
* - rankings: prints all players' ranks
|
||||
* - whitelist: adds an admin to the whitelist to use DM commands
|
||||
* - getwhitelist: prints the whitelist
|
||||
* - clearwhitelist: clears the whitelist completely, security measure
|
||||
*/
|
||||
client.on("messageCreate", async (message) => {
|
||||
if (message.author.bot || message.guild) return;
|
||||
|
||||
@ -316,13 +325,13 @@ client.on("messageCreate", async (message) => {
|
||||
}
|
||||
|
||||
if (message.content.toLowerCase().includes("hello penguin")) {
|
||||
await message.reply(`hello ${message.author.username}`);
|
||||
await message.reply(`Hello ${message.author.username}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const pickupGuild = client.guilds.cache.get(GUILD_ID);
|
||||
if (!pickupGuild) {
|
||||
await message.reply("could not find guild");
|
||||
await message.reply("Could not find guild");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -331,7 +340,7 @@ client.on("messageCreate", async (message) => {
|
||||
if (args[0] === "setrank") {
|
||||
if (args.length < 3) {
|
||||
await message.reply(
|
||||
"invalid number of arguments. usage: `setrank <player name or id> <rank (0-5)>`"
|
||||
"Invalid number of arguments. usage: `setrank <player name or id> <rank (0-5)>`"
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -339,7 +348,7 @@ client.on("messageCreate", async (message) => {
|
||||
const player = findPlayer(pickupGuild, args[1]);
|
||||
if (!player) {
|
||||
await message.reply(
|
||||
`could not find player ${args[1]}. if this issue persists, try copy/pasting the player's discord handle or user id`
|
||||
`Could not find player ${args[1]}. If this issue persists, try copy/pasting the player's Discord handle or user ID`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -350,7 +359,7 @@ client.on("messageCreate", async (message) => {
|
||||
const rank = parseInt(args[2]);
|
||||
if (isNaN(rank) || rank < 0 || rank > 5) {
|
||||
await message.reply(
|
||||
`invalid rank ${args[2]}. must be an integer between 0 and 5`
|
||||
`Invalid rank ${args[2]}. Supply an integer between 0 and 5`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -366,7 +375,7 @@ client.on("messageCreate", async (message) => {
|
||||
rankings[playerId] = rank;
|
||||
|
||||
console.log(
|
||||
`setting rank of ${applicableName}, ${playerId} to ${rank} at ${rankingsPath}...`
|
||||
`Setting rank of ${applicableName}, ${playerId} to ${rank} at ${rankingsPath}...`
|
||||
);
|
||||
new Promise((resolve, reject) => {
|
||||
fs.writeFile(rankingsPath, JSON.stringify(rankings), (err) => {
|
||||
@ -376,9 +385,9 @@ client.on("messageCreate", async (message) => {
|
||||
}).then((res, err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
message.reply(`error setting rank: ${err.message}`);
|
||||
message.reply(`Error setting rank: ${err.message}`);
|
||||
} else {
|
||||
message.reply(`set rank of ${applicableName} to ${rank}`);
|
||||
message.reply(`Set rank of ${applicableName} to ${rank}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -386,7 +395,7 @@ client.on("messageCreate", async (message) => {
|
||||
if (args[0] === "getrank") {
|
||||
if (args.length < 2) {
|
||||
await message.reply(
|
||||
"invalid number of arguments. usage: `getrank <player name or id>`"
|
||||
"Invalid number of arguments. Usage: `getrank <player name or id>`"
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -394,7 +403,7 @@ client.on("messageCreate", async (message) => {
|
||||
const player = findPlayer(pickupGuild, args[1]);
|
||||
if (!player) {
|
||||
await message.reply(
|
||||
`could not find player ${args[1]}. if this issue persists, try using the player's id`
|
||||
`Could not find player ${args[1]}. If this issue persists, try copy/pasting the player's Discord handle or user ID`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -404,7 +413,7 @@ client.on("messageCreate", async (message) => {
|
||||
|
||||
try {
|
||||
console.log(
|
||||
`getting rank of ${applicableName}, ${playerId} at ${rankingsPath}...`
|
||||
`Getting rank of ${applicableName}, ${playerId} at ${rankingsPath}...`
|
||||
);
|
||||
if (!fs.existsSync(rankingsPath)) {
|
||||
fs.writeFileSync(rankingsPath, "{}");
|
||||
@ -417,14 +426,14 @@ client.on("messageCreate", async (message) => {
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await message.reply(`error getting rank: ${error.message}`);
|
||||
await message.reply(`Error getting rank: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0] === "rankings") {
|
||||
await message.reply("getting rankings...");
|
||||
await message.reply("Getting rankings...");
|
||||
try {
|
||||
console.log(`getting rankings at ${rankingsPath}...`);
|
||||
console.log(`Getting rankings at ${rankingsPath}...`);
|
||||
if (!fs.existsSync(rankingsPath)) {
|
||||
fs.writeFileSync(rankingsPath, "{}");
|
||||
}
|
||||
@ -453,11 +462,11 @@ client.on("messageCreate", async (message) => {
|
||||
str += `${name.padEnd(maxNameLength, " ")} - ${"*".repeat(rank)}\n`;
|
||||
}
|
||||
str += backticks;
|
||||
if (str === backticks + backticks) str = "no rankings found";
|
||||
if (str === backticks + backticks) str = "No rankings found";
|
||||
await message.reply(str);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await message.reply(`error getting rankings: ${error.message}`);
|
||||
await message.reply(`Error getting rankings: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +474,7 @@ client.on("messageCreate", async (message) => {
|
||||
// add user to config.json whitelist
|
||||
if (args.length < 2) {
|
||||
await message.reply(
|
||||
"invalid number of arguments. usage: `whitelist <name>`"
|
||||
"Invalid number of arguments. Usage: `whitelist <name>`"
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -474,7 +483,7 @@ client.on("messageCreate", async (message) => {
|
||||
const player = findPlayer(pickupGuild, name);
|
||||
if (!player) {
|
||||
await message.reply(
|
||||
`could not find player ${name}. if this issue persists, try copy/pasting the player's discord handle or user id`
|
||||
`Could not find player ${name}. If this issue persists, try copy/pasting the player's Discord handle or user ID`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -484,7 +493,7 @@ client.on("messageCreate", async (message) => {
|
||||
|
||||
if (whitelistStr.includes(playerId)) {
|
||||
await message.reply(
|
||||
`user ${applicableName} (${playerId}) is already whitelisted`
|
||||
`User ${applicableName} (${playerId}) is already whitelisted`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -501,10 +510,10 @@ client.on("messageCreate", async (message) => {
|
||||
}).then((res, err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
message.reply(`error whitelisting user: ${err.message}`);
|
||||
message.reply(`Error whitelisting user: ${err.message}`);
|
||||
} else {
|
||||
message.reply(
|
||||
`whitelisted user ${applicableName} (${playerId}). if this was done in error, please contact an admin`
|
||||
`Whitelisted user ${applicableName} (${playerId}). If this was done in error, please contact an admin`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -526,7 +535,7 @@ client.on("messageCreate", async (message) => {
|
||||
if (args[0] === "clearwhitelist") {
|
||||
if (args[1] !== "confirm") {
|
||||
await message.reply(
|
||||
"this command will clear the whitelist and prevent further dm commands. this will require manual intervention to undo. to confirm, use `clearwhitelist confirm`"
|
||||
"This command will clear the whitelist and prevent further DM commands. This will require manual intervention to undo. To confirm, use `clearwhitelist confirm`"
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
@ -542,9 +551,9 @@ client.on("messageCreate", async (message) => {
|
||||
}).then((res, err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
message.reply(`error clearing whitelist: ${err.message}`);
|
||||
message.reply(`Error clearing whitelist: ${err.message}`);
|
||||
} else {
|
||||
message.reply("whitelist cleared, please alert an admin");
|
||||
message.reply("Whitelist cleared, please alert an admin");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user