Compare commits
3 Commits
eee43d2976
...
6ee679ffd4
Author | SHA1 | Date | |
---|---|---|---|
6ee679ffd4 | |||
e2ad1e18b4 | |||
ae61e4761f |
85
src/index.js
85
src/index.js
@ -49,12 +49,12 @@ client.on('interactionCreate', async(interaction) => {
|
||||
const gearType = interaction.options.get('geartype').value;
|
||||
const employee = interaction.options.get('employee').value;
|
||||
if ( addRemove == 'add') {
|
||||
AddGear(gearType, employee)
|
||||
interaction.reply(`Added a gear to ${employee}`)
|
||||
const gearAdded = AddGear(gearType, employee)
|
||||
interaction.reply({content: `Added a ${gearAdded} to ${employee}`, ephemeral: true})
|
||||
};
|
||||
|
||||
} 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) {
|
||||
@ -69,7 +69,7 @@ client.on('interactionCreate', async(interaction) => {
|
||||
interaction.reply(`Fired ${employeeName}`)
|
||||
}
|
||||
} 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) {
|
||||
@ -78,7 +78,7 @@ client.on('interactionCreate', async(interaction) => {
|
||||
PromoteEmployee(employeeName, rank);
|
||||
interaction.reply(`Changed ${employeeName}\'s rank to ${rank}`);
|
||||
} 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) {
|
||||
@ -91,37 +91,74 @@ client.on('interactionCreate', async(interaction) => {
|
||||
if (interaction.commandName === 'scoreboard' && isManager) {
|
||||
const updateOrDisplay = interaction.options.get('update-display').value;
|
||||
const gearchannel = client.channels.cache.get('1255024866797682779');
|
||||
let scoreBoardMessage = await BuildScoreboard("Beastboss");
|
||||
scoreBoardMessage += await BuildScoreboard("Manager");
|
||||
scoreBoardMessage += await BuildScoreboard("Muscle");
|
||||
scoreBoardMessage += await BuildScoreboard("Moneymaker");
|
||||
scoreBoardMessage += await BuildScoreboard("Mystic");
|
||||
scoreBoardMessage += await BuildScoreboard("Intern");
|
||||
let scoreBoardMessageBeastboss = await BuildScoreboard("Beastboss");
|
||||
let scoreBoardMessageManager = await BuildScoreboard("Manager");
|
||||
let scoreBoardMessageMuscle = await BuildScoreboard("Muscle");
|
||||
let scoreBoardMessageMoneymaker = await BuildScoreboard("Moneymaker");
|
||||
let scoreBoardMessageMystic = await BuildScoreboard("Mystic");
|
||||
let scoreBoardMessageIntern = await BuildScoreboard("Intern");
|
||||
if (updateOrDisplay == 'display') {
|
||||
console.log("Scoreboard goes here: " + scoreBoardMessage);
|
||||
//console.log("Scoreboard goes here: " + scoreBoardMessage);
|
||||
|
||||
if (scoreBoardMessage != "") {
|
||||
gearchannel.send(scoreBoardMessage);
|
||||
interaction.reply("Displaying Scoreboard");
|
||||
if (scoreBoardMessageIntern != "") {
|
||||
gearchannel.send(scoreBoardMessageBeastboss);
|
||||
gearchannel.send(scoreBoardMessageManager);
|
||||
gearchannel.send(scoreBoardMessageMuscle);
|
||||
gearchannel.send(scoreBoardMessageMoneymaker);
|
||||
gearchannel.send(scoreBoardMessageMystic);
|
||||
gearchannel.send(scoreBoardMessageIntern);
|
||||
interaction.reply({content: "Displaying Scoreboard", ephemeral: true});
|
||||
}
|
||||
else {
|
||||
console.log("Something went wrong when building the scoreboard.");
|
||||
};
|
||||
};
|
||||
if (updateOrDisplay == 'update') {
|
||||
const messagesInGearchannel = await gearchannel.messages.fetch()
|
||||
const gearMessage = await messagesInGearchannel.find(msg => msg.author.id === '1306647733490290809')
|
||||
gearchannel.messages.fetch().then((messages) => {
|
||||
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) {
|
||||
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 {
|
||||
gearMessage.edit(scoreBoardMessage);
|
||||
gearMessage.edit(scoreBoardMessageBeastboss);
|
||||
interaction.reply("Updated scoreboard.")
|
||||
}
|
||||
} */
|
||||
}
|
||||
} 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"){
|
||||
Type += "gear";
|
||||
}
|
||||
if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return
|
||||
db.run(`UPDATE Employees SET ${Type} = ${Type} + 1 WHERE name = \'${Employee}\' `)
|
||||
if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return "Nothing";
|
||||
db.run(`UPDATE Employees SET ${Type} = ${Type} + 1 WHERE name = \'${Employee}\' `);
|
||||
|
||||
return Type;
|
||||
};
|
||||
function RemoveGear(Type, Employee) {
|
||||
if (Type != "coppergear" && Type != "silvergear" && Type != "goldgear" && Type != "purplegear") return
|
||||
|
Loading…
Reference in New Issue
Block a user