Compare commits

..

3 Commits

View File

@ -49,12 +49,12 @@ client.on('interactionCreate', async(interaction) => {
const gearType = interaction.options.get('geartype').value; const gearType = interaction.options.get('geartype').value;
const employee = interaction.options.get('employee').value; const employee = interaction.options.get('employee').value;
if ( addRemove == 'add') { if ( addRemove == 'add') {
AddGear(gearType, employee) const gearAdded = AddGear(gearType, employee)
interaction.reply(`Added a gear to ${employee}`) interaction.reply({content: `Added a ${gearAdded} to ${employee}`, ephemeral: true})
}; };
} else if (interaction.commandName === 'gear' && !isManager) { } else if (interaction.commandName === 'gear' && !isManager) {
interaction.reply("You aren't a manager! Get back to work.") interaction.reply({content:"You aren't a manager! Get back to work.", ephemeral: true})
}; };
if (interaction.commandName === 'employee' && isManager) { if (interaction.commandName === 'employee' && isManager) {
@ -69,7 +69,7 @@ client.on('interactionCreate', async(interaction) => {
interaction.reply(`Fired ${employeeName}`) interaction.reply(`Fired ${employeeName}`)
} }
} else if (interaction.commandName === 'employee' && !isManager) { } else if (interaction.commandName === 'employee' && !isManager) {
interaction.reply("You aren't a manager! Get back to work.") interaction.reply({content:"You aren't a manager! Get back to work.", ephemeral: true})
}; };
if (interaction.commandName === 'promote' && isManager) { if (interaction.commandName === 'promote' && isManager) {
@ -78,7 +78,7 @@ client.on('interactionCreate', async(interaction) => {
PromoteEmployee(employeeName, rank); PromoteEmployee(employeeName, rank);
interaction.reply(`Changed ${employeeName}\'s rank to ${rank}`); interaction.reply(`Changed ${employeeName}\'s rank to ${rank}`);
} else if (interaction.commandName === 'promote' && !isManager) { } else if (interaction.commandName === 'promote' && !isManager) {
interaction.reply("You aren't a manager! Get back to work.") interaction.reply({content:"You aren't a manager! Get back to work.", ephemeral: true})
}; };
if (interaction.commandName === 'rename' && isManager) { if (interaction.commandName === 'rename' && isManager) {
@ -91,37 +91,74 @@ client.on('interactionCreate', async(interaction) => {
if (interaction.commandName === 'scoreboard' && isManager) { if (interaction.commandName === 'scoreboard' && isManager) {
const updateOrDisplay = interaction.options.get('update-display').value; const updateOrDisplay = interaction.options.get('update-display').value;
const gearchannel = client.channels.cache.get('1255024866797682779'); const gearchannel = client.channels.cache.get('1255024866797682779');
let scoreBoardMessage = await BuildScoreboard("Beastboss"); let scoreBoardMessageBeastboss = await BuildScoreboard("Beastboss");
scoreBoardMessage += await BuildScoreboard("Manager"); let scoreBoardMessageManager = await BuildScoreboard("Manager");
scoreBoardMessage += await BuildScoreboard("Muscle"); let scoreBoardMessageMuscle = await BuildScoreboard("Muscle");
scoreBoardMessage += await BuildScoreboard("Moneymaker"); let scoreBoardMessageMoneymaker = await BuildScoreboard("Moneymaker");
scoreBoardMessage += await BuildScoreboard("Mystic"); let scoreBoardMessageMystic = await BuildScoreboard("Mystic");
scoreBoardMessage += await BuildScoreboard("Intern"); let scoreBoardMessageIntern = await BuildScoreboard("Intern");
if (updateOrDisplay == 'display') { if (updateOrDisplay == 'display') {
console.log("Scoreboard goes here: " + scoreBoardMessage); //console.log("Scoreboard goes here: " + scoreBoardMessage);
if (scoreBoardMessage != "") { if (scoreBoardMessageIntern != "") {
gearchannel.send(scoreBoardMessage); gearchannel.send(scoreBoardMessageBeastboss);
interaction.reply("Displaying Scoreboard"); gearchannel.send(scoreBoardMessageManager);
gearchannel.send(scoreBoardMessageMuscle);
gearchannel.send(scoreBoardMessageMoneymaker);
gearchannel.send(scoreBoardMessageMystic);
gearchannel.send(scoreBoardMessageIntern);
interaction.reply({content: "Displaying Scoreboard", ephemeral: true});
} }
else { else {
console.log("Something went wrong when building the scoreboard."); console.log("Something went wrong when building the scoreboard.");
}; };
}; };
if (updateOrDisplay == 'update') { if (updateOrDisplay == 'update') {
const messagesInGearchannel = await gearchannel.messages.fetch() gearchannel.messages.fetch().then((messages) => {
const gearMessage = await messagesInGearchannel.find(msg => msg.author.id === '1306647733490290809') let replyMessage = "";
for (const message of messages) {
if(message[1].content.includes("# Beastboss") && message[1].editable) {
message[1].edit(scoreBoardMessageBeastboss);
replyMessage += "Updated Beastboss \n"
}
if (message[1].content.includes("# Manager") && message[1].editable ) {
message[1].edit(scoreBoardMessageManager);
replyMessage += "Updated Manager \n"
}
if (message[1].content.includes("# Muscle") && message[1].editable) {
message[1].edit(scoreBoardMessageMuscle);
replyMessage += "Updated Muscle \n"
}
if (message[1].content.includes("# Moneymaker") && message[1].editable) {
message[1].edit(scoreBoardMessageMuscle);
replyMessage += "Updated Moneymaker \n"
}
if (message[1].content.includes("# Mystic") && message[1].editable) {
message[1].edit(scoreBoardMessageMuscle);
replyMessage += "Updated Mystic \n"
}
if (message[1].content.includes("# Intern") && message[1].editable) {
message[1].edit(scoreBoardMessageMuscle);
replyMessage += "Updated Intern \n"
}
};
interaction.reply({content: replyMessage, ephemeral: true});
})
/*
const gearMessage = await messagesInGearchannel.find(msg => msg.author.id === '1306647733490290809' && msg.content.includes("#Beastboss"));
if (gearMessage === undefined) { if (gearMessage === undefined) {
interaction.reply("Could not find a message to update, did you remember to display it first?"); interaction.reply({content: "Could not find a message to update, did you remember to display it first?", ephemeral: true});
console.log(messagesInGearchannel);
console.log(messagesInGearchannel.length())
} }
else { else {
gearMessage.edit(scoreBoardMessage); gearMessage.edit(scoreBoardMessageBeastboss);
interaction.reply("Updated scoreboard.") interaction.reply("Updated scoreboard.")
} } */
} }
} else if (interaction.commandName === 'scoreboard' && !isManager) { } else if (interaction.commandName === 'scoreboard' && !isManager) {
interaction.reply("You aren't a manager! Get back to work.") interaction.reply({content:"You aren't a manager! Get back to work.", ephemeral: true})
}; };
}); });
@ -141,8 +178,10 @@ function AddGear(Type,Employee) {
if (Type == "copper" || Type == "silver" || Type == "gold" || Type == "purple"){ if (Type == "copper" || Type == "silver" || Type == "gold" || Type == "purple"){
Type += "gear"; Type += "gear";
} }
if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return "Nothing";
db.run(`UPDATE Employees SET ${Type} = ${Type} + 1 WHERE name = \'${Employee}\' `) db.run(`UPDATE Employees SET ${Type} = ${Type} + 1 WHERE name = \'${Employee}\' `);
return Type;
}; };
function RemoveGear(Type, Employee) { function RemoveGear(Type, Employee) {
if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return