This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
124 lines (119 loc) · 5.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const fs = require('fs');//import all modules required, if you get an error run npm i <missing module> in the shell
const GameBoyAdvance = require('gbajs');//the module that helped to make this bot
const Discord = require('discord.js');
const client = new Discord.Client();
const gba = new GameBoyAdvance();
var filePath = './gba1.png';
var biosBuf = fs.readFileSync('./node_modules/gbajs/resources/bios.bin');
gba.setBios(biosBuf);
gba.setCanvasMemory();
const disbut = require('discord-buttons')(client);
const [Abutton,Bbutton,R,L,Start,Select,Left,Right,Up,Down] = require('./buttons.js')
const config = require('./config.json')
gba.logLevel = gba.LOG_ERROR;
gba.loadRomFromFile('./game.gba', function(err, result) {
if (err) {
console.error('loadRom failed:', err);
process.exit(1);
}
gba.runStable();
});
const Game = gba.screenshot();
const keypad = gba.keypad;
client.on('ready', ready => {
console.log('ready')
})
let admin = [config.devID, config.devID2];
client.on('message',message => {
if (!admin.includes(message.author.id)) return;
if(message.author.bot) return;
if(!message.content.startsWith('$gba')) return;
if(message.content.startsWith('$gba'))
message.channel.send(`The GBA Developed By **${config.devName}** <a:Black_Fire:819183722573987840>\nControls - 🎮`,{buttons:[Abutton,Bbutton,Start,Select]})
});
client.on('message',message => {
if (!admin.includes(message.author.id)) return;
if(message.author.bot) return;
if(!message.content.startsWith('$gba')) return;
if(message.content.startsWith('$gba'))
message.channel.send('`Keys`',{buttons:[Up,Down,Left,Right]})
});
client.on('message',message => {
if (!admin.includes(message.author.id)) return;
if(message.author.bot) return;
if(!message.content.startsWith('$gba')) return;
if(message.content.startsWith('$gba'))
message.channel.send('`HELP`',{buttons:[L,R]})
});
var idx = 1;
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_a_id') {
keypad.press(keypad.A)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_b_id') {
keypad.press(keypad.B)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_up_id') {
keypad.press(keypad.UP)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_down_id') {
keypad.press(keypad.DOWN)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_left_id') {
keypad.press(keypad.LEFT)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_right_id') {
keypad.press(keypad.RIGHT)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_select_id') {
keypad.press(keypad.SELECT)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_start_id') {
keypad.press(keypad.START)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_l_id') {
keypad.press(keypad.L)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.on('clickButton', async (button) => {
if (button.id === 'secret_gba_r_id') {
keypad.press(keypad.R)
await gba.screenshot().pack().pipe(fs.createWriteStream('gba' + idx + '.png'))
await button.channel.send({files: ['./gba1.png']}).then(msg =>{setTimeout(() => msg.delete(), 800)})
}
});
client.login(config.Token)