-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.ts
32 lines (27 loc) · 922 Bytes
/
bot.ts
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
import * as Discord from 'discord.js';
import { configuration } from './config';
var botName = require('./package.json').name;
var botVersion = require('./package.json').version;
const bot = new Discord.Client();
bot.login(configuration.auth.token);
bot.on('ready', function(evt: any) {
console.info('Connected');
console.info('Logged in as: ');
console.info(bot.user.username + ' - (' + bot.user.id + ')');
});
bot.on('message', async (message: Discord.Message) => {
if (message.author.bot) {
return;
}
const prefix = '!ogecho';
if (!message.content.startsWith(prefix)) {
return;
}
const content = message.content.replace(prefix, '').trim();
if (content === 'version') {
await message.channel.send(`${botName}: ${botVersion}`);
} else {
const output = `Received:\n\`\`\`\n${content}\n\`\`\``;
await message.reply(output);
}
});