1- import { ApplicationCommandOptionType , EmbedBuilder } from "discord.js" ;
1+ import { ApplicationCommandOptionType } from "discord.js" ;
22import { eq } from "drizzle-orm" ;
33import { db , watchListPingsTable , watchListTable } from "#db" ;
44import { Command } from "#structures" ;
@@ -18,7 +18,7 @@ export default new Command<"chatInput">({
1818 const reference = interaction . options . getString ( "reference" , false ) ;
1919 const watchListData = ( await db . select ( ) . from ( watchListTable ) . where ( eq ( watchListTable . name , name ) ) ) . at ( 0 ) ;
2020
21- if ( watchListData ) return await interaction . reply ( `\`${ name } \` already exists for reason \`${ watchListData . reason } \`` ) ;
21+ if ( watchListData ) return interaction . reply ( `\`${ name } \` already exists for reason \`${ watchListData . reason } \`` ) ;
2222
2323 if ( reference && ! regExp . test ( reference ) ) return interaction . reply ( "Invalid reference, must be a message link!" ) ;
2424
@@ -29,21 +29,25 @@ export default new Command<"chatInput">({
2929 reference
3030 } ) ;
3131
32- const severityText = severity === "ban" ? "banned" : "watched over" ;
33- const referenceText = reference ? `\nReference: ${ reference } ` : "" ;
32+ let resultText = `Successfully added \`${ name } \`` ;
3433
35- await interaction . reply ( `Successfully added \`${ name } \` who needs to be **${ severityText } ** with reason \`${ reason } \`${ referenceText } ` ) ;
34+ resultText += `\nReason: ${ reason } ` ;
35+ resultText += `\nSeverity: **${ severity === "ban" ? "Needs banning" : "Needs watching over" } **` ;
36+
37+ if ( reference ) resultText += `\nReference: ${ reference } ` ;
38+
39+ await interaction . reply ( resultText ) ;
3640
3741 break ;
3842 } ;
3943 case "update" : {
40- const reason = interaction . options . getString ( "reason" , false ) ;
4144 const name = interaction . options . getString ( "username" , true ) ;
45+ const reason = interaction . options . getString ( "reason" , false ) ;
4246 const severity = interaction . options . getString ( "severity" , false ) as "ban" | "watch" | null ;
4347 const reference = interaction . options . getString ( "reference" , false ) ;
4448 const watchListData = ( await db . select ( ) . from ( watchListTable ) . where ( eq ( watchListTable . name , name ) ) ) . at ( 0 ) ;
4549
46- if ( ! watchListData ) return interaction . reply ( `\`${ name } \` doesn't exist on watchList ` ) ;
50+ if ( ! watchListData ) return interaction . reply ( `\`${ name } \` doesn't exist on watch list ` ) ;
4751
4852 if ( reference && ! regExp . test ( reference ) ) return interaction . reply ( "Invalid reference, must be a message link!" ) ;
4953
@@ -56,19 +60,27 @@ export default new Command<"chatInput">({
5660 } )
5761 . where ( eq ( watchListTable . name , name ) ) ;
5862
59- await interaction . reply ( `Successfully updated watchList details for \`${ name } \`` ) ;
63+ let resultContent = `Successfully updated watch list details for \`${ name } \`` ;
64+
65+ if ( reason ) resultContent += `\nReason: \`${ reason } \`` ;
66+
67+ if ( severity ) resultContent += `\nSeverity: **${ severity === "ban" ? "Needs banning" : "Needs watching over" } **` ;
68+
69+ if ( reference ) resultContent += `\nReference: \`${ reference } \`` ;
70+
71+ await interaction . reply ( resultContent ) ;
6072
6173 break ;
6274 }
6375 case "remove" : {
6476 const name = interaction . options . getString ( "username" , true ) ;
6577 const watchListData = ( await db . select ( ) . from ( watchListTable ) . where ( eq ( watchListTable . name , name ) ) ) . at ( 0 ) ;
6678
67- if ( ! watchListData ) return await interaction . reply ( `\`${ name } \` doesn't exist on watchList ` ) ;
79+ if ( ! watchListData ) return interaction . reply ( `\`${ name } \` doesn't exist on watch list ` ) ;
6880
6981 await db . delete ( watchListTable ) . where ( eq ( watchListTable . name , name ) ) ;
7082
71- await interaction . reply ( `Successfully removed \`${ name } \` from watchList ` ) ;
83+ await interaction . reply ( `Successfully removed \`${ name } \` from watch list ` ) ;
7284
7385 break ;
7486 } ;
@@ -82,17 +94,17 @@ export default new Command<"chatInput">({
8294 if ( playerData ) {
8395 await interaction . reply (
8496 `Player name: \`${ playerData . name } \`` +
85- `\nReason: ** ${ playerData . reason } ** ` +
86- " \nSeverity: " + ( playerData . isSevere ? "** Needs banning** " : "** Needs watching over**" ) +
97+ `\nReason: ${ playerData . reason } ` +
98+ ` \nSeverity: ** ${ ( playerData . isSevere ? "Needs banning" : "Needs watching over" ) } **` +
8799 ( playerData . reference ? `\nReference: ${ playerData . reference } ` : "" )
88100 ) ;
89101 } else {
90- await interaction . reply ( `No watch list details found with username \`${ username } \`` ) ;
102+ await interaction . reply ( `\`${ username } \` doesn't exist on watch list ` ) ;
91103 }
92104 } else {
93105 await interaction . reply ( { files : [ {
94106 attachment : Buffer . from ( JSON . stringify ( watchListData , null , 2 ) ) ,
95- name : "watch_List .json"
107+ name : "watch_list .json"
96108 } ] } ) ;
97109 }
98110
@@ -104,37 +116,24 @@ export default new Command<"chatInput">({
104116 if ( ! watchListPingsData . some ( x => x . userId === interaction . user . id ) ) {
105117 await db . insert ( watchListPingsTable ) . values ( { userId : interaction . user . id } ) ;
106118
107- return await interaction . reply ( { embeds : [ new EmbedBuilder ( )
108- . setDescription ( "You have successfully subscribed to watchList notifications" )
109- . setFooter ( { text : "Run this command again to unsubscribe" } )
110- . setColor ( interaction . client . config . EMBED_COLOR )
111- ] } ) ;
119+ return interaction . reply (
120+ "Successfully subscribed to watch list notifications for players needing banning" +
121+ "\n-# Run this command again to unsubscribe"
122+ ) ;
112123 }
113124
114125 await collectAck ( {
115126 interaction,
116127 payload : {
117- embeds : [ new EmbedBuilder ( )
118- . setDescription ( "You are already subscribed to watchList notifications, do you want to unsubscribe?" )
119- . setColor ( interaction . client . config . EMBED_COLOR )
120- ]
128+ content : "You are already subscribed to watch list notifications. Do you want to unsubscribe?"
121129 } ,
122130 async confirm ( int ) {
123131 await db . delete ( watchListPingsTable ) . where ( eq ( watchListPingsTable . userId , interaction . user . id ) ) ;
124132
125- await int . update ( {
126- embeds : [ new EmbedBuilder ( )
127- . setDescription ( "You have successfully unsubscribed from watchList notifications" )
128- . setColor ( interaction . client . config . EMBED_COLOR )
129- ] ,
130- components : [ ]
131- } ) ;
133+ await int . update ( { content : "Successfully unsubscribed from watch list notifications" , components : [ ] } ) ;
132134 } ,
133135 async cancel ( int ) {
134- await int . update ( {
135- embeds : [ new EmbedBuilder ( ) . setDescription ( "Command canceled" ) . setColor ( interaction . client . config . EMBED_COLOR ) ] ,
136- components : [ ]
137- } ) ;
136+ await int . update ( { content : "Command canceled" , components : [ ] } ) ;
138137 } ,
139138 } ) ;
140139
@@ -149,7 +148,7 @@ export default new Command<"chatInput">({
149148 {
150149 type : ApplicationCommandOptionType . Subcommand ,
151150 name : "add" ,
152- description : "Add a player to watchList " ,
151+ description : "Add a player to watch list " ,
153152 options : [
154153 {
155154 type : ApplicationCommandOptionType . String ,
@@ -169,7 +168,7 @@ export default new Command<"chatInput">({
169168 description : "Whether this player needs to be banned or watched over" ,
170169 choices : [
171170 { name : "Needs to be banned" , value : "ban" } ,
172- { name : "Needs to be watched over" , value : "watch" }
171+ { name : "Needs watching over" , value : "watch" }
173172 ] ,
174173 required : true
175174 } ,
@@ -184,7 +183,7 @@ export default new Command<"chatInput">({
184183 {
185184 type : ApplicationCommandOptionType . Subcommand ,
186185 name : "update" ,
187- description : "Update the details of a watchList entry" ,
186+ description : "Update the details of a watch list entry" ,
188187 options : [
189188 {
190189 type : ApplicationCommandOptionType . String ,
@@ -204,7 +203,7 @@ export default new Command<"chatInput">({
204203 description : "Update whether this player needs to be banned or watched over" ,
205204 choices : [
206205 { name : "Needs to be banned" , value : "ban" } ,
207- { name : "Needs to be watched over" , value : "watch" }
206+ { name : "Needs watching over" , value : "watch" }
208207 ] ,
209208 required : false
210209 } ,
@@ -219,7 +218,7 @@ export default new Command<"chatInput">({
219218 {
220219 type : ApplicationCommandOptionType . Subcommand ,
221220 name : "remove" ,
222- description : "Remove a player from watchList " ,
221+ description : "Remove a player from watch list " ,
223222 options : [
224223 {
225224 type : ApplicationCommandOptionType . String ,
@@ -245,7 +244,7 @@ export default new Command<"chatInput">({
245244 {
246245 type : ApplicationCommandOptionType . Subcommand ,
247246 name : "notifications" ,
248- description : "Manage your subscription to watchList notifications"
247+ description : "Manage your subscription to watch list notifications"
249248 }
250249 ]
251250 }
0 commit comments