View difference between Paste ID: JDXb1Kfg and zCGCGbkY
SHOW: | | - or go back to the newest paste.
1
// Main file
2
3
const fs = require('fs');
4
const Discord = require('discord.js');
5
const config = require('./config.json');
6
const client = new Discord.Client();
7
client.commands = new Discord.Collection();
8
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
9
for (const file of commandFiles) {
10
	const command = require(`./commands/${file}`);
11
12
	// set a new item in the Collection
13
	// with the key as the command name and the value as the exported module
14
	client.commands.set(command.name, command);
15
}
16
const arr = [
17
	"1",
18
];
19
20
client.once('ready', () => {
21
	console.log('Ready!');
22
	client.user.setActivity("Memes and War, and hopes you will too!");
23
    // Temp logger code - this comes back as true.
24
	var isArr = Array.isArray(arr);
25
	console.log(`${isArr}`)
26
    // End temp logger
27
});
28
29
client.on('message', async message => {
30
	if(message.author.bot) return;
31
	if(message.content.includes('murica') && message.channel.id === ('783389789591437333')){
32
		message.channel.send(`https://giphy.com/gifs/freedom-murica-UGGGGjJUsvx84`)
33
		return
34
	}
35
36
	if (!message.content.startsWith(config.prefix)) return;
37
38
	const args = message.content.slice(config.prefix.length).trim().split(/ +/);
39
	const commandName = args.shift().toLowerCase();
40
41
	console.log(`Args below\n${args}\nEnd args`)
42
43
	const command = client.commands.get(commandName)
44
		|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
45
	
46
	if (!command) return;
47
48
	if (command.guildOnly && message.channel.type === 'dm') {
49
	return message.reply('I can\'t execute that command inside DMs!');
50
	}
51
52
	if (command.args && !args.length) {
53
		return message.channel.send(`You didn't provide any arguments, ${message.author}!`);
54
	}
55
56
	await command.execute(message, args, client, arr);
57
});
58
59
client.on("error", (e) => console.error(e));
60
client.on("warn", (e) => console.warn(e));
61
62
client.login(config.token);
63
64
// End main file, start remove number command
65
66
module.exports = {
67
	name: 'endgame',
68
	description: 'End a game. Requires the Administrator permission!',
69
	async execute(message, args, arr) {
70
		if (message.member.hasPermission('ADMINISTRATOR')){
71
			const gametoend = parseInt(args[0])
72
			console.log(`This is the game to end: ${gametoend}`)
73
			//	if (!gametoend.length) {
74
			//return message.channel.send(`You need to specify which game to delete ${message.author}!`);
75
			//}
76
			if (isNaN(gametoend)) {
77
				return message.reply('that doesn\'t seem to be a valid number.');
78
			}
79
80
			if(arr.indexOf(gametoend) === -1){
81
				message.reply('that game doesn\'t exist! Did you put in the wrong number?');
82
			} else {
83
				message.channel.send('Placeholder success');
84
				arr.remove(gametoend);
85
				console.log(arr);
86
				message.channel.send('Placeholder success 2');
87
				return;
88
			}
89
		} else {
90
			message.channel.send('Sorry - you need the Administrator permission to do this command!')
91
		}
92
	},
93
};