Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Main file
- const fs = require('fs');
- const Discord = require('discord.js');
- const config = require('./config.json');
- const client = new Discord.Client();
- client.commands = new Discord.Collection();
- const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
- for (const file of commandFiles) {
- const command = require(`./commands/${file}`);
- // set a new item in the Collection
- // with the key as the command name and the value as the exported module
- client.commands.set(command.name, command);
- }
- const arr = [
- "1",
- ];
- client.once('ready', () => {
- console.log('Ready!');
- client.user.setActivity("Memes and War, and hopes you will too!");
- // Temp logger code - this comes back as true.
- var isArr = Array.isArray(arr);
- console.log(`${isArr}`)
- // End temp logger
- });
- client.on('message', async message => {
- if(message.author.bot) return;
- if(message.content.includes('murica') && message.channel.id === ('783389789591437333')){
- message.channel.send(`https://giphy.com/gifs/freedom-murica-UGGGGjJUsvx84`)
- return
- }
- if (!message.content.startsWith(config.prefix)) return;
- const args = message.content.slice(config.prefix.length).trim().split(/ +/);
- const commandName = args.shift().toLowerCase();
- console.log(`Args below\n${args}\nEnd args`)
- const command = client.commands.get(commandName)
- || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
- if (!command) return;
- if (command.guildOnly && message.channel.type === 'dm') {
- return message.reply('I can\'t execute that command inside DMs!');
- }
- if (command.args && !args.length) {
- return message.channel.send(`You didn't provide any arguments, ${message.author}!`);
- }
- await command.execute(message, args, client, arr);
- });
- client.on("error", (e) => console.error(e));
- client.on("warn", (e) => console.warn(e));
- client.login(config.token);
- // End main file, start remove number command
- module.exports = {
- name: 'endgame',
- description: 'End a game. Requires the Administrator permission!',
- async execute(message, args, arr) {
- if (message.member.hasPermission('ADMINISTRATOR')){
- const gametoend = parseInt(args[0])
- console.log(`This is the game to end: ${gametoend}`)
- // if (!gametoend.length) {
- //return message.channel.send(`You need to specify which game to delete ${message.author}!`);
- //}
- if (isNaN(gametoend)) {
- return message.reply('that doesn\'t seem to be a valid number.');
- }
- if(arr.indexOf(gametoend) === -1){
- message.reply('that game doesn\'t exist! Did you put in the wrong number?');
- } else {
- message.channel.send('Placeholder success');
- arr.remove(gametoend);
- console.log(arr);
- message.channel.send('Placeholder success 2');
- return;
- }
- } else {
- message.channel.send('Sorry - you need the Administrator permission to do this command!')
- }
- },
- };
Add Comment
Please, Sign In to add comment