Skip to content

Commit 9296919

Browse files
committed
New Commands
1 parent 1ab613f commit 9296919

3 files changed

Lines changed: 275 additions & 0 deletions

File tree

Commands/Games/catchthefish.js

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
module.exports = {
2+
name: 'catchthefish',
3+
aliases: [],
4+
run: async (client, message, args) => {
5+
const positions = {
6+
safe: '_ _ :fish:\n _ _ :hand_splayed:\n _ _ :cat:',
7+
danger: '_ _ :bomb:\n _ _ :hand_splayed:\n _ _ :cat:',
8+
win: '_ _ :crown:**You won.**:crown:\n_ _ :hand_splayed:\n_ _ :cat:',
9+
lose: '_ _ :skull:**You lost.**:skull: \n_ _ :hand_splayed:\n_ _ :cat:',
10+
};
11+
12+
let randomized = Math.floor(Math.random() * 2);
13+
let gameEnded = false;
14+
let randomPos = positions[Object.keys(positions)[randomized]];
15+
let data = 0;
16+
17+
const componentsArray = [
18+
{
19+
type: 1,
20+
components: [
21+
{
22+
type: 2,
23+
style: 'SECONDARY',
24+
custom_id: 'e',
25+
label: '\u200b',
26+
disabled: true,
27+
},
28+
{
29+
type: 2,
30+
style: 'PRIMARY',
31+
custom_id: String(Math.random()),
32+
emoji: { id: '890611575227023391' },
33+
},
34+
{
35+
type: 2,
36+
style: 'SECONDARY',
37+
custom_id: 'ee',
38+
label: '\u200b',
39+
disabled: true,
40+
},
41+
],
42+
},
43+
];
44+
45+
const msg = await message.channel.send({
46+
content: `Catch 3 fishes to win!\n\n${randomPos}`,
47+
components: componentsArray,
48+
});
49+
50+
const filter = (button => { return button.user.id === message.author.id; });
51+
const game = await message.channel.createMessageComponentCollector({
52+
filter,
53+
componentType: 'BUTTON',
54+
});
55+
56+
function update(button) {
57+
randomized = Math.floor(Math.random() * 2);
58+
randomPos = positions[Object.keys(positions)[randomized]];
59+
60+
if(data === 3) {
61+
gameEnded = true;
62+
game.stop();
63+
componentsArray[0].components[1].disabled = true;
64+
65+
msg.edit({
66+
content: positions.win,
67+
components: componentsArray,
68+
});
69+
button.reply({ content: 'GG! You caught 3 fishes!' });
70+
}
71+
else if (data <= -9) {
72+
gameEnded = true;
73+
game.stop();
74+
componentsArray[0].components[1].disabled = true;
75+
76+
msg.edit({
77+
content: positions.lose,
78+
components: componentsArray,
79+
});
80+
button.reply({ content: 'GG You lost XD' });
81+
}
82+
else {
83+
if(button) return button.deferUpdate();
84+
msg.edit({
85+
content: randomPos + ` **${data}**`,
86+
components: componentsArray,
87+
});
88+
}
89+
}
90+
91+
setInterval(() => {
92+
if(gameEnded === false) return update();
93+
}, 2000);
94+
95+
game.on('collect', async (button) => {
96+
if(randomized !== 0) {
97+
data -= 3;
98+
update(button);
99+
}
100+
else {
101+
data++;
102+
update(button);
103+
}
104+
});
105+
},
106+
};

Commands/Games/football.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module.exports = {
2+
name: 'football',
3+
aliases: [],
4+
run: async (client, message, args) => {
5+
const positions = {
6+
left: '_ _ 🥅🥅🥅\n_ _ 🕴️\n \n_ _ ⚽',
7+
middle: '_ _ 🥅🥅🥅\n_ _ 🕴️\n \n_ _ ⚽',
8+
right: '_ _ 🥅🥅🥅\n_ _ 🕴️\n \n_ _ ⚽',
9+
};
10+
let randomized = Math.floor(Math.random() * Object.keys(positions).length);
11+
let gameEnded = false;
12+
let randomPos = positions[Object.keys(positions)[randomized]];
13+
14+
const componentsArray = [
15+
{
16+
type: 1,
17+
components: [
18+
{
19+
type: 2,
20+
style: 'SECONDARY',
21+
custom_id: 'left',
22+
label: 'Left',
23+
},
24+
{
25+
type: 2,
26+
style: 'PRIMARY',
27+
custom_id: 'middle',
28+
label: 'Middle',
29+
},
30+
{
31+
type: 2,
32+
style: 'SECONDARY',
33+
custom_id: 'right',
34+
label: 'Right',
35+
},
36+
],
37+
},
38+
];
39+
40+
const msg = await message.channel.send({
41+
content: randomPos,
42+
components: componentsArray,
43+
});
44+
function update() {
45+
randomized = Math.floor(Math.random() * Object.keys(positions).length);
46+
randomPos = positions[Object.keys(positions)[randomized]];
47+
48+
msg.edit({
49+
content: randomPos,
50+
components: componentsArray,
51+
});
52+
}
53+
setInterval(() => {
54+
if(gameEnded == false) return update();
55+
}, 1000);
56+
57+
const filter = button => {
58+
return button.user.id === message.author.id;
59+
};
60+
const button = await msg.awaitMessageComponent({ filter: filter, componentType: 'BUTTON', max: 1 });
61+
62+
if(button.customId !== Object.keys(positions)[randomized]) {
63+
gameEnded = true;
64+
return button.reply({ content: 'You won!' });
65+
}
66+
else {
67+
gameEnded = true;
68+
return button.reply({ content: 'You lose...' });
69+
}
70+
},
71+
};

Commands/Games/gunfight.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
module.exports = {
2+
name: 'gunfight',
3+
description: "First one to shoot wins!",
4+
aliases: ['gf'],
5+
run: async (client, message, args) => {
6+
const opponent = message.mentions.users.first();
7+
const positions = {
8+
three: '_ _ :levitate: :point_right: **3** :point_left: :levitate:',
9+
two: '_ _ :levitate: :point_right: **2** :point_left: :levitate:',
10+
one: '_ _ :levitate: :point_right: **1** :point_left: :levitate:',
11+
go: '_ _ :levitate: :point_right: **GO!** :point_left: :levitate:',
12+
ended1: '_ _ :levitate: :point_right: **STOP!** :skull_crossbones: :levitate:',
13+
ended2: '_ _ :levitate: :skull_crossbones: **STOP!** :point_left: :levitate:',
14+
};
15+
16+
const componentsArray = [
17+
{
18+
type: 1,
19+
components: [
20+
{
21+
type: 2,
22+
label: 'Shoot!',
23+
custom_id: 'shoot1',
24+
style: 'PRIMARY',
25+
disabled: true,
26+
},
27+
{
28+
type: 2,
29+
label: '\u200b',
30+
custom_id: 'id lol useless',
31+
style: 'SECONDARY',
32+
disabled: true,
33+
},
34+
{
35+
type: 2,
36+
label: 'Shoot!',
37+
custom_id: 'shoot2',
38+
style: 'DANGER',
39+
disabled: true,
40+
},
41+
],
42+
},
43+
];
44+
45+
const msg = await message.channel.send({
46+
content: positions.three,
47+
components: componentsArray,
48+
});
49+
50+
function countdown() {
51+
setTimeout(() => {
52+
msg.edit({
53+
content: positions.two,
54+
components: componentsArray,
55+
});
56+
}, 1000);
57+
setTimeout(() => {
58+
msg.edit({
59+
content: positions.one,
60+
components: componentsArray,
61+
});
62+
}, 2000);
63+
setTimeout(() => {
64+
componentsArray[0].components[0].disabled = false;
65+
componentsArray[0].components[2].disabled = false;
66+
msg.edit({
67+
content: positions.go,
68+
components: componentsArray,
69+
});
70+
}, 3000);
71+
}
72+
countdown();
73+
74+
const filter = button => {
75+
return button.user.id == message.author.id || button.user.id == opponent.id;
76+
};
77+
78+
const button = await msg.awaitMessageComponent({ filter: filter, componentType: 'BUTTON', max: 1 });
79+
80+
componentsArray[0].components[0].disabled = true;
81+
componentsArray[0].components[2].disabled = true;
82+
83+
if(button.customId === 'shoot1' && button.user.id == message.author.id) {
84+
msg.edit({
85+
content: positions.ended1,
86+
components: componentsArray,
87+
});
88+
return button.reply({ content: `<@${message.author.id}> won!` });
89+
}
90+
else if(button.customId === 'shoot2' && button.user.id == opponent.id) {
91+
msg.edit({
92+
content: positions.ended1,
93+
components: componentsArray,
94+
});
95+
return button.reply({ content: `<@${opponent.id}> won!` });
96+
}
97+
},
98+
};

0 commit comments

Comments
 (0)