fix: Patched DM bug exploit
This commit is contained in:
13
index.js
13
index.js
@ -80,6 +80,10 @@ client.once(Events.ClientReady, async () => {
|
||||
});
|
||||
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.guild) {
|
||||
return interaction.reply({ content: 'This feature can only be used in a server.' });
|
||||
}
|
||||
|
||||
// Slash command: /register
|
||||
if (interaction.isChatInputCommand() && interaction.commandName === 'register') {
|
||||
// Check if loggingChannel is set
|
||||
@ -230,8 +234,8 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||
|
||||
// Check for available keys
|
||||
data = loadData();
|
||||
const keyCount = data.keys ? data.keys.length : 0;
|
||||
if (keyCount === 0) {
|
||||
const keyCheck = data.keys ? data.keys.length : 0;
|
||||
if (keyCheck === 0) {
|
||||
if (data.loggingChannel) {
|
||||
|
||||
if (channel) {
|
||||
@ -243,6 +247,7 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||
|
||||
// Assign and remove key from vault
|
||||
const key = data.keys.shift();
|
||||
const keyCount = data.keys.length;
|
||||
user = { id: interaction.user.id, key };
|
||||
data.users.push(user);
|
||||
saveData(data);
|
||||
@ -251,9 +256,9 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||
if (data.loggingChannel) {
|
||||
if (channel) {
|
||||
if (keyCount <= 10) {
|
||||
channel.send(`⚠️ Only ${data.keys.length} keys left in the vault!`);
|
||||
channel.send(`⚠️ Only ${keyCount} keys left in the vault!`);
|
||||
} else if (keyCount <= 50) {
|
||||
channel.send(`⚠️ Only ${data.keys.length} keys left in the vault.`);
|
||||
channel.send(`⚠️ Only ${keyCount} keys left in the vault.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user