Move closereq to ephemeral & add permission check
This commit is contained in:
parent
457c52ba0c
commit
8e08dbbf0f
13
functions.js
13
functions.js
@ -10,6 +10,8 @@ const dbPass = process.env.dbPass;
|
|||||||
const dbPort = process.env.dbPort;
|
const dbPort = process.env.dbPort;
|
||||||
const isDev = process.env.isDev;
|
const isDev = process.env.isDev;
|
||||||
|
|
||||||
|
const ownerId = process.env.ownerId;
|
||||||
|
|
||||||
// filesystem
|
// filesystem
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
@ -435,12 +437,21 @@ const functions = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Parent-Level functions (miscellaneuous)
|
// Parent-Level functions (miscellaneuous)
|
||||||
closeRequest(requestId, client) {
|
closeRequest(requestId, interaction) {
|
||||||
|
if (interaction.user.id == ownerId) {
|
||||||
|
const { client } = interaction;
|
||||||
const query = `UPDATE requests SET status = 'Closed' WHERE id = ${db.escape(requestId)}`;
|
const query = `UPDATE requests SET status = 'Closed' WHERE id = ${db.escape(requestId)}`;
|
||||||
db.query(query, (err, rows, fields) => {
|
db.query(query, (err, rows, fields) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
functions.download.requests(client);
|
functions.download.requests(client);
|
||||||
});
|
});
|
||||||
|
interaction.reply({ content: `Request #${requestId} has been closed.`, ephemeral: true });
|
||||||
|
} else {
|
||||||
|
interaction.reply({ content: 'You do not have permission to do that.', ephemeral: true });
|
||||||
|
}
|
||||||
|
if (isDev) {
|
||||||
|
console.log(requestId, interaction, ownerId);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
spongebob(commandData) {
|
spongebob(commandData) {
|
||||||
let flipper = 0;
|
let flipper = 0;
|
||||||
|
@ -11,7 +11,6 @@ module.exports = {
|
|||||||
.setRequired(true)),
|
.setRequired(true)),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
const requestId = interaction.options.getString('requestid');
|
const requestId = interaction.options.getString('requestid');
|
||||||
fn.closeRequest(requestId, interaction.client);
|
fn.closeRequest(requestId, interaction);
|
||||||
interaction.reply(`Request #${requestId} closed.`);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user