Restructure
This commit is contained in:
parent
e851b7d169
commit
bbf98e0a2a
|
@ -1 +1,2 @@
|
|||
DISCORD_TOKEN=MAOISYHRO9
|
||||
PREFIX=.
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
name: 'delete',
|
||||
description: 'Delete a specified number of your messages.',
|
||||
async execute(message, args, deleteTimeout) {
|
||||
const deleteCount = parseInt(args[0], 10);
|
||||
|
||||
if (isNaN(deleteCount)) {
|
||||
const errorMsg = await message.channel.send('Please provide the number of messages to delete.');
|
||||
setTimeout(() => errorMsg.delete().catch(console.error), deleteTimeout);
|
||||
return;
|
||||
}
|
||||
|
||||
const messages = await message.channel.messages.fetch({ limit: deleteCount + 1 });
|
||||
const filtered = messages.filter(msg => msg.author.id === message.author.id);
|
||||
filtered.forEach(msg => {
|
||||
msg.delete().catch(console.error);
|
||||
});
|
||||
},
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'List all of my commands or info about a specific command.',
|
||||
execute(message, args, deleteTimeout) {
|
||||
let reply = 'Here are my supported commands:\n\n';
|
||||
const commands = Array.from(message.client.commands.values());
|
||||
reply += commands.map(command => `.${command.name} - ${command.description}`).join('\n');
|
||||
|
||||
message.channel.send(reply).then(sentMessage => {
|
||||
setTimeout(() => sentMessage.delete().catch(console.error), deleteTimeout);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
require('dotenv').config();
|
||||
const { Client } = require('discord.js-selfbot-v13');
|
||||
const client = new Client();
|
||||
const fs = require('fs');
|
||||
|
||||
const PREFIX = process.env.PREFIX || '.';
|
||||
const MESSAGE_DELETE_TIMEOUT = 10000
|
||||
|
||||
client.commands = new Map();
|
||||
|
||||
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`./commands/${file}`);
|
||||
client.commands.set(command.name, command);
|
||||
}
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log(`Logged in as ${client.user.tag}!`);
|
||||
});
|
||||
|
||||
client.on('messageCreate', async message => {
|
||||
if (message.author.id !== client.user.id || !message.content.startsWith(PREFIX)) return;
|
||||
|
||||
const args = message.content.slice(1).split(/ +/);
|
||||
const commandName = args.shift().toLowerCase();
|
||||
|
||||
if (!client.commands.has(commandName)) return;
|
||||
|
||||
message.delete();
|
||||
|
||||
try {
|
||||
await client.commands.get(commandName).execute(message, args, MESSAGE_DELETE_TIMEOUT);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.channel.send('There was an error trying to execute that command!')
|
||||
.then(sentMessage => {
|
||||
setTimeout(() => sentMessage.delete().catch(console.error), MESSAGE_DELETE_TIMEOUT);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
client.login(process.env.DISCORD_TOKEN);
|
27
main.js
27
main.js
|
@ -1,27 +0,0 @@
|
|||
require('dotenv').config();
|
||||
const { Client } = require('discord.js-selfbot-v13');
|
||||
const client = new Client();
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log(`Logged in as ${client.user.tag}!`);
|
||||
});
|
||||
|
||||
client.on('messageCreate', async message => {
|
||||
if (message.author.id !== client.user.id) return;
|
||||
|
||||
if (message.content.startsWith('.delete')) {
|
||||
const args = message.content.split(' ').slice(1);
|
||||
const deleteCount = parseInt(args[0], 10);
|
||||
|
||||
if (!isNaN(deleteCount)) {
|
||||
const messages = await message.channel.messages.fetch({ limit: deleteCount + 1 });
|
||||
const filtered = messages.filter(msg => msg.author.id === client.user.id);
|
||||
filtered.forEach(msg => msg.delete().catch(console.error));
|
||||
}
|
||||
} else if (message.content === '.help') {
|
||||
message.channel.send('`.delete [number]` - Deletes a specified number of your messages.\n`.help` - Shows this help message.');
|
||||
}
|
||||
});
|
||||
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
|
Loading…
Reference in New Issue