@@ -2,136 +2,136 @@ const { SlashCommandBuilder, ChannelType } = require('discord.js');
22const adminDb = require ( '../database/admindb' ) ;
33
44const data = new SlashCommandBuilder ( )
5- . setName ( 'admin' )
6- . setDescription ( 'Interact with the admin console' )
7- . addSubcommand ( subCommand =>
8- subCommand
9- . setName ( 'allow-bot-shame-replies' )
10- . setDescription ( 'Allows the bot to reply to shamed users' )
11- . addBooleanOption ( option =>
12- option
13- . setName ( 'allow' )
14- . setDescription ( 'Is bot allowed to send replies to shamed' )
15- . setRequired ( true )
16- )
5+ . setName ( 'admin' )
6+ . setDescription ( 'Interact with the admin console' )
7+ . addSubcommand ( subCommand =>
8+ subCommand
9+ . setName ( 'allow-bot-shame-replies' )
10+ . setDescription ( 'Allows the bot to reply to shamed users' )
11+ . addBooleanOption ( option =>
12+ option
13+ . setName ( 'allow' )
14+ . setDescription ( 'Is bot allowed to send replies to shamed' )
15+ . setRequired ( true )
16+ )
17+ )
18+ . addSubcommand ( subCommand =>
19+ subCommand
20+ . setName ( 'set-challenge-channel' )
21+ . setDescription ( 'Sets the channel send challenge reminders' )
22+ . addChannelOption ( option =>
23+ option
24+ . setName ( 'channel' )
25+ . setDescription ( 'Name of the channel to send challenge reminders to' )
26+ . addChannelTypes ( ChannelType . GuildText )
27+ . setRequired ( true )
28+ )
29+ )
30+ . addSubcommand ( subCommand =>
31+ subCommand
32+ . setName ( 'show-challenge-channel' )
33+ . setDescription ( 'Shows which channel gets challenge reminders' )
34+ )
35+ . addSubcommand ( subCommand =>
36+ subCommand
37+ . setName ( 'set-shamed-role' )
38+ . setDescription ( 'Set the role to use for the shamed one' )
39+ . addRoleOption ( option =>
40+ option
41+ . setName ( 'role' )
42+ . setDescription ( 'The role to use to notify for shamed one reminders' )
43+ . setRequired ( true )
1744 )
18- . addSubcommand ( subCommand =>
19- subCommand
20- . setName ( 'set-challenge-channel' )
21- . setDescription ( 'Sets the channel send challenge reminders' )
22- . addChannelOption ( option =>
23- option
24- . setName ( 'channel' )
25- . setDescription ( 'Name of the channel to send challenge reminders to' )
26- . addChannelTypes ( ChannelType . GuildText )
27- . setRequired ( true )
28- )
29- )
30- . addSubcommand ( subCommand =>
31- subCommand
32- . setName ( 'show-challenge-channel' )
33- . setDescription ( 'Shows which channel gets challenge reminders' )
34- )
35- . addSubcommand ( subCommand =>
36- subCommand
37- . setName ( 'set-shamed-role' )
38- . setDescription ( 'Set the role to use for the shamed one' )
39- . addRoleOption ( option =>
40- option
41- . setName ( 'role' )
42- . setDescription ( 'The role to use to notify for shamed one reminders' )
43- . setRequired ( true )
44- )
45- )
46- . addSubcommand ( subCommand =>
47- subCommand
48- . setName ( 'show-shamed-role' )
49- . setDescription ( 'Shows which role is for the shamed' )
50- ) ;
45+ )
46+ . addSubcommand ( subCommand =>
47+ subCommand
48+ . setName ( 'show-shamed-role' )
49+ . setDescription ( 'Shows which role is for the shamed' )
50+ ) ;
5151
5252async function allowBotShameReplies ( interaction ) {
53- const allowed = interaction . options . getBoolean ( 'allow' ) ;
54- const rows = await adminDb . Admin . update ( { allowbotshamereplies : allowed } , { where : { singleid : 0 } } ) ;
55- if ( rows == 0 ) {
56- buildDefaultDb ( ) ;
57- await adminDb . Admin . update ( { allowbotshamereplies : allowed } , { where : { singleid : 0 } } ) ;
58- }
59- if ( allowed ) {
60- await interaction . reply ( 'Bot can now post replies to shamed users' ) ;
61- } else {
62- await interaction . reply ( 'Bot can no longer post replies to shamed users' ) ;
63- }
53+ const allowed = interaction . options . getBoolean ( 'allow' ) ;
54+ const rows = await adminDb . Admin . update ( { allowbotshamereplies : allowed } , { where : { singleid : 0 } } ) ;
55+ if ( rows == 0 ) {
56+ buildDefaultDb ( ) ;
57+ await adminDb . Admin . update ( { allowbotshamereplies : allowed } , { where : { singleid : 0 } } ) ;
58+ }
59+ if ( allowed ) {
60+ await interaction . reply ( 'Bot can now post replies to shamed users' ) ;
61+ } else {
62+ await interaction . reply ( 'Bot can no longer post replies to shamed users' ) ;
63+ }
6464}
6565
6666async function setChallengeChannel ( interaction ) {
67- const channel = interaction . options . getChannel ( 'channel' ) ;
68- const savedId = channel . id . toString ( ) ;
69- console . debug ( `Saving channel id ${ savedId } ` ) ;
67+ const channel = interaction . options . getChannel ( 'channel' ) ;
68+ const savedId = channel . id . toString ( ) ;
69+ console . debug ( `Saving channel id ${ savedId } ` ) ;
7070
71- const rows = await adminDb . Admin . update ( { challengechannelid : savedId } , { where : { singleid : 0 } } ) ;
72- if ( rows == 0 ) {
73- buildDefaultDb ( ) ;
74- await adminDb . Admin . update ( { challengechannelid : savedId } , { where : { singleid : 0 } } ) ;
75- }
76- await interaction . reply ( `Challenge reminders will now be sent to <#${ savedId } >` ) ;
71+ const rows = await adminDb . Admin . update ( { challengechannelid : savedId } , { where : { singleid : 0 } } ) ;
72+ if ( rows == 0 ) {
73+ buildDefaultDb ( ) ;
74+ await adminDb . Admin . update ( { challengechannelid : savedId } , { where : { singleid : 0 } } ) ;
75+ }
76+ await interaction . reply ( `Challenge reminders will now be sent to <#${ savedId } >` ) ;
7777}
7878
7979async function showChallengeChannel ( interaction ) {
80- const db = await adminDb . Admin . findOne ( { where : { singleid : 0 } } ) ;
81- if ( db ) {
82- await interaction . reply ( `The channel for challenge reminders is <#${ db . challengechannelid } >` ) ;
83- } else {
84- await interaction . reply ( 'No channel has been set' ) ;
85- }
80+ const db = await adminDb . Admin . findOne ( { where : { singleid : 0 } } ) ;
81+ if ( db ) {
82+ await interaction . reply ( `The channel for challenge reminders is <#${ db . challengechannelid } >` ) ;
83+ } else {
84+ await interaction . reply ( 'No channel has been set' ) ;
85+ }
8686}
8787
8888async function setShamedOneRole ( interaction ) {
89- const role = interaction . options . getRole ( 'role' ) ;
90- const savedId = role . id . toString ( ) ;
91- console . debug ( `Saving role id ${ savedId } ` ) ;
89+ const role = interaction . options . getRole ( 'role' ) ;
90+ const savedId = role . id . toString ( ) ;
91+ console . debug ( `Saving role id ${ savedId } ` ) ;
9292
93- const rows = await adminDb . Admin . update ( { shamedroleid : savedId } , { where : { singleid : 0 } } ) ;
94- if ( rows == 0 ) {
95- buildDefaultDb ( ) ;
96- await adminDb . Admin . update ( { shamedroleid : savedId } , { where : { singleid : 0 } } ) ;
97- }
98- await interaction . reply ( `Shamed one role has been set to <@&${ savedId } >` ) ;
93+ const rows = await adminDb . Admin . update ( { shamedroleid : savedId } , { where : { singleid : 0 } } ) ;
94+ if ( rows == 0 ) {
95+ buildDefaultDb ( ) ;
96+ await adminDb . Admin . update ( { shamedroleid : savedId } , { where : { singleid : 0 } } ) ;
97+ }
98+ await interaction . reply ( `Shamed one role has been set to <@&${ savedId } >` ) ;
9999}
100100
101101async function showShamedOneRole ( interaction ) {
102- const db = await adminDb . Admin . findOne ( { where : { singleid : 0 } } ) ;
103- if ( db ) {
104- await interaction . reply ( `The role for the shamed <@&${ db . shamedroleid } >` ) ;
105- } else {
106- await interaction . reply ( 'No role has been set' ) ;
107- }
102+ const db = await adminDb . Admin . findOne ( { where : { singleid : 0 } } ) ;
103+ if ( db ) {
104+ await interaction . reply ( `The role for the shamed <@&${ db . shamedroleid } >` ) ;
105+ } else {
106+ await interaction . reply ( 'No role has been set' ) ;
107+ }
108108}
109109
110110async function buildDefaultDb ( ) {
111- await adminDb . Admin . create ( {
112- singleid : 0 ,
113- challengechannelid : '0' ,
114- shamedroleid : '0'
115- } ) ;
111+ await adminDb . Admin . create ( {
112+ singleid : 0 ,
113+ challengechannelid : '0' ,
114+ shamedroleid : '0'
115+ } ) ;
116116}
117117
118118module . exports = {
119- cooldown : 5 ,
120- data : data ,
121- async execute ( interaction ) {
122- const subCommand = interaction . options . getSubcommand ( ) ;
123- if ( subCommand === 'allow-bot-shame-replies' ) {
124- allowBotShameReplies ( interaction ) ;
125- } else if ( subCommand === 'set-challenge-channel' ) {
126- setChallengeChannel ( interaction ) ;
127- } else if ( subCommand === 'set-shamed-role' ) {
128- setShamedOneRole ( interaction ) ;
129- } else if ( subCommand === 'show-challenge-channel' ) {
130- showChallengeChannel ( interaction ) ;
131- } else if ( subCommand === 'show-shamed-role' ) {
132- showShamedOneRole ( interaction ) ;
133- } else {
134- await interaction . reply ( 'Unknown command' ) ;
135- }
136- }
119+ cooldown : 5 ,
120+ data : data ,
121+ async execute ( interaction ) {
122+ const subCommand = interaction . options . getSubcommand ( ) ;
123+ if ( subCommand === 'allow-bot-shame-replies' ) {
124+ allowBotShameReplies ( interaction ) ;
125+ } else if ( subCommand === 'set-challenge-channel' ) {
126+ setChallengeChannel ( interaction ) ;
127+ } else if ( subCommand === 'set-shamed-role' ) {
128+ setShamedOneRole ( interaction ) ;
129+ } else if ( subCommand === 'show-challenge-channel' ) {
130+ showChallengeChannel ( interaction ) ;
131+ } else if ( subCommand === 'show-shamed-role' ) {
132+ showShamedOneRole ( interaction ) ;
133+ } else {
134+ await interaction . reply ( 'Unknown command' ) ;
135+ }
136+ }
137137} ;
0 commit comments