-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (35 loc) · 1.13 KB
/
index.js
File metadata and controls
47 lines (35 loc) · 1.13 KB
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
require('dotenv').config();
const { Client, Embed } = require('guilded.ts');
const Sentry = require('@sentry/node');
const FleetyardsBot = require('./fleetyards-bot');
Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
});
const run = () => {
const client = new Client();
const guilded_token = process.env.GUILDED_API_TOKEN;
// This event is emitted when your bot is connected to Guilded's Gateway API.
client.once('ready', () =>
console.info(`[READY] Logged in as ${client.user.name}.`),
);
// This event is emitted when a message is sent on Guilded.
client.on('messageCreate', async (message) => {
if (message.createdBy === client.user.id) return;
const [botName, ...args] = message.content.split(' ');
if (botName !== `@${client.user.name}`) return;
console.info('[MESSAGE]', message.content);
fleetyardsBot = new FleetyardsBot(new Embed());
const result = await fleetyardsBot.resolve(args);
message.reply(result);
});
// Log into guilded
client.login(guilded_token);
};
setTimeout(() => {
try {
run();
} catch (e) {
Sentry.captureException(e);
}
}, 99);