This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
80 lines (68 loc) · 1.69 KB
/
index.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
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
import 'dotenv/config';
import {
Command,
config,
Mammot,
option,
forced,
Mentionable,
} from '@mammot/core';
import {CommandInteraction, Intents, User} from 'discord.js';
const mammot = Mammot.client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
],
developmentGuild: process.env.DEVELOPMENT_GUILD_ID!,
async onError(interaction, error) {
mammot.warn(error);
return Promise.resolve('Something went wrong!');
},
onReady(user) {
mammot.success(`Logged into client as ${user.username}`);
},
});
const codeblock = (v: string) => `\`\`\`${v}\`\`\``;
@config('ratio', {description: 'Command will ratio somebody'})
class Ratio extends Command {
public async run(
interaction: CommandInteraction,
// Required arguments go before optional arguments
@option('user', {
description: 'The user to ratio',
required: true,
})
user: User,
@forced('mention', {
description: 'Just a placeholder value',
type: 'MENTIONABLE',
required: true,
})
mention: Mentionable,
// Optional values can safely use the ? operator in `param?: type`
@option('amount', {
description: 'Another placeholder value',
type: 'INTEGER',
})
amount?: number,
) {
await interaction.channel?.send(`<@${user.id}> get ratioeddd`);
await interaction.reply({
ephemeral: true,
content: codeblock(JSON.stringify({amount, mention}, null, 2)),
});
}
}
@config('ping', {
description: 'ping pong!',
})
class Ping extends Command {
public async run(interaction: CommandInteraction) {
await interaction.reply({
content: ':ninja:',
ephemeral: true,
});
}
}
void mammot.addCommands([Ratio, Ping]).login(process.env.DISCORD_TOKEN);