forked from GeorgeCiesinski/poke-guesser-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeout.js
136 lines (130 loc) · 3.99 KB
/
timeout.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const { ApplicationCommandType, ApplicationCommandOptionType } = require('discord.js');
const util = require("./util");
async function timeout(interaction, subcommand, lang, db) {
let response = {
title: '',
description: ''
};
switch (subcommand) {
case 'set':
try {
let d = interaction.options.getInteger('days', false) || 0;
let h = interaction.options.getInteger('hours', false) || 0;
let m = interaction.options.getInteger('minutes', false) || 0;
let s = interaction.options.getInteger('seconds', false) || 0;
await setTimeout(interaction.guildId, interaction.options.getUser('user').id, d, h, m, s);
response.title = lang.obj['mod_timeout_set_title_success'];
response.description = lang.obj['mod_timeout_set_description_success'];
} catch (err) {
response.title = lang.obj['mod_timeout_set_title_failed'];
response.description = `${lang.obj['mod_timeout_set_description_failed']}${err}`;
}
break;
case 'unset':
try {
await unsetTimeout(interaction.guildId, interaction.options.getUser('user').id);
response.title = lang.obj['mod_timeout_unset_title_success'];
response.description = lang.obj['mod_timeout_unset_description_success'];
} catch (err) {
response.title = lang.obj['mod_timeout_unset_title_failed'];
response.description = `${lang.obj['mod_timeout_unset_description_failed']}${err}`;
}
break;
case 'show':
try {
await showTimeout(interaction.guildId, interaction.options.getUser('user').id);
response.title = lang.obj['mod_timeout_show_title_success'];
response.description = lang.obj['mod_timeout_show_description_success'];
} catch (err) {
response.title = lang.obj['mod_timeout_show_title_failed'];
response.description = `${lang.obj['mod_timeout_show_description_failed']}${err}`;
}
break;
}
// returnEmbed(title, message, image=null)
return response;
}
function setTimeout(serverId, userId, days = 0, hours = 0, minutes = 0, seconds = 0) {
// TODO: Execute Mod Actions
}
function unsetTimeout(serverId, userId) {
// TODO: Execute Mod Actions
}
function showTimeout(serverId, userId) {
// TODO: Execute Mod Actions
}
function getRegisterObject() {
return {
name: 'timeout',
description: 'Manage the timeout of someone',
type: ApplicationCommandOptionType.SubcommandGroup,
options: [
{
name: 'set',
description: 'Sets a users timeout',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'user',
description: 'The user whose timeout you want to set',
required: true,
type: ApplicationCommandOptionType.User
},
{
name: 'days',
description: 'The time you want to set the timeout to',
required: false,
type: ApplicationCommandOptionType.Integer
},
{
name: 'hours',
description: 'The time you want to set the timeout to',
required: false,
type: ApplicationCommandOptionType.Integer
},
{
name: 'minutes',
description: 'The time you want to set the timeout to',
required: false,
type: ApplicationCommandOptionType.Integer
},
{
name: 'seconds',
description: 'The time you want to set the timeout to',
required: false,
type: ApplicationCommandOptionType.Integer
}
]
},
{
name: 'unset',
description: 'Unsets a users timeout',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'user',
description: 'The user whose timeout you want to unset',
required: true,
type: ApplicationCommandOptionType.User
}
]
},
{
name: 'show',
description: 'Shows a users timeout',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'user',
description: 'The user whose score you want to show',
required: true,
type: ApplicationCommandOptionType.User
}
]
}
]
};
}
// Exports each function separately
module.exports.timeout = timeout;
module.exports.getRegisterObject = getRegisterObject;