-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (50 loc) · 1.85 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
require("dotenv").config(); // Get your bot tokens
const { Client, EVENT } = require("dogehouse.js");
const { defaultRoom, prefix } = require('./config.json');
const getByValue = require('./common/getCommandAliases.js');
// Handlers
const { commands } = require('./commands.js');
const { events } = require('./events.js');
// Connect to dogehouse
const token = process.env.DOGEHOUSE_TOKEN;
const refreshToken = process.env.DOGEHOUSE_REFRESH_TOKEN;
const app = new Client();
app.connect(token, refreshToken).then(async () => {
console.log("Bot connected.");
app.rooms.join(defaultRoom); // This will allow you to join a room.
});
// Defining your message listener
app.on(EVENT.NEW_CHAT_MESSAGE, async (message) => {
console.log(`${message.author.username}: ${message.content}`);
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift();
const command = commands.get(commandName) || commands.get(getByValue(commands, commandName));
const data = {commands: commands, app: app, message: message};
if (!command) return;
try {
command.execute(data, args)
} catch (e) {
console.log(e)
}
});
app.on(EVENT.BOT_JOINED_ROOM, async ({room}) => {
console.log("EVENT.BOT_JOINED_ROOM");
if (room) {
console.log({Room: room.name, VoiceServer: room.voiceServer})
app.bot.sendMessage(`Connected to Room: ${room.name} | My commands --> ${prefix}help`);
}
});
// Sending message outside of a Chat event
app.on(EVENT.USER_JOINED_ROOM, (user) => {
console.log(`EVENT.USER_JOINED_ROOM- ${user.username}`);
const data = {events: events, app: app, user: user};
events.forEach(event => {
try {
if (event.event == 'EVENT.USER_JOINED_ROOM')
event.execute(data)
} catch (e) {
console.log(e)
}
});
});