-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
118 lines (83 loc) · 2.53 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
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Intents } = require('discord.js');
const NodeWebcam = require('node-webcam')
const { token } = require('./config.json');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
client.commands.set(command.data.name, command);
}
client.once('ready', () => {
console.log('Ready!');
client.user.setPresence({
game: { name: "Staring out Pat's window" },
status: 'online',
});
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
client.login(token);
const synchronizeSlashCommands = require('discord-sync-commands');
synchronizeSlashCommands(client, [
{
name: 'ping',
description: 'Replies with Pong'
}, {
name: 'server',
description: 'Replies with Server info'
}, {
name: 'window',
description: "Takes a picture of Pat's Window"
}
], {
debug: true,
});
var opts = {
//Picture related
width: 640,
height: 480,
quality: 100,
// Number of frames to capture
// More the frames, longer it takes to capture
// Use higher framerate for quality. Ex: 60
frames: 60,
//Delay in seconds to take shot
//if the platform supports miliseconds
//use a float (0.1)
//Currently only on windows
delay: 0,
//Save shots in memory
saveShots: true,
// [jpeg, png] support varies
// Webcam.OutputTypes
output: "png",
//Which camera to use
//Use Webcam.list() for results
//false for default device
device: false,
// [location, buffer, base64]
// Webcam.CallbackReturnTypes
callbackReturn: "location",
//Logging
verbose: false
};
const Webcam = NodeWebcam.create(opts);
setInterval(() => {
Webcam.capture("window", function (err, data) {
console.log(err, data)
});
}, 30 * 1000)