@@ -80,7 +80,12 @@ var Commands = []discord.ApplicationCommandCreate{
80
80
},
81
81
discord.ApplicationCommandOptionString {
82
82
Name : "proxy" ,
83
- Description : "the proxy to use for the post links such as: https://rxddit.com" ,
83
+ Description : "the proxy to use for the post links such as: https://rxddit.com or https://vxreddit.com" ,
84
+ Required : false ,
85
+ },
86
+ discord.ApplicationCommandOptionBool {
87
+ Name : "link-button" ,
88
+ Description : "whether to include a link button in the post (default: true)" ,
84
89
Required : false ,
85
90
},
86
91
},
@@ -116,6 +121,11 @@ var Commands = []discord.ApplicationCommandCreate{
116
121
Description : "the proxy to use for the post links such as: https://rxddit.com" ,
117
122
Required : false ,
118
123
},
124
+ discord.ApplicationCommandOptionBool {
125
+ Name : "link-button" ,
126
+ Description : "whether to include a link button in the post (default: true)" ,
127
+ Required : false ,
128
+ },
119
129
},
120
130
},
121
131
discord.ApplicationCommandOptionSubCommand {
@@ -180,6 +190,10 @@ func (b *Bot) OnSubredditAdd(data discord.SlashCommandInteractionData, event *ev
180
190
}
181
191
roleID := data .Snowflake ("role" )
182
192
proxy := data .String ("proxy" )
193
+ linkButton , ok := data .OptBool ("link-button" )
194
+ if ! ok {
195
+ linkButton = true
196
+ }
183
197
184
198
ok , err := b .db .HasSubscriptionByGuildSubreddit (* event .GuildID (), subreddit )
185
199
if err != nil {
@@ -215,6 +229,7 @@ func (b *Bot) OnSubredditAdd(data discord.SlashCommandInteractionData, event *ev
215
229
FormatType : FormatType (formatType ),
216
230
RoleID : roleID ,
217
231
RedditProxy : proxy ,
232
+ LinkButton : linkButton ,
218
233
Interaction : event .ApplicationCommandInteraction ,
219
234
}
220
235
_ = event .CreateMessage (discord.MessageCreate {
@@ -251,14 +266,15 @@ func (b *Bot) OnSubredditAdd(data discord.SlashCommandInteractionData, event *ev
251
266
return
252
267
}
253
268
254
- if err = b .db . AddSubscription (Subscription {
269
+ if err = b .AddSubscription (Subscription {
255
270
Subreddit : subreddit ,
256
271
Type : postType ,
257
272
FormatType : FormatType (formatType ),
258
273
GuildID : * event .GuildID (),
259
274
ChannelID : event .Channel ().ID (),
260
275
WebhookID : webhook .ID (),
261
276
WebhookToken : webhook .Token ,
277
+ LinkButton : linkButton ,
262
278
}); err != nil {
263
279
_ = event .CreateMessage (discord.MessageCreate {
264
280
Content : "Failed to save subscription to the database: " + err .Error (),
@@ -278,6 +294,7 @@ func (b *Bot) OnSubredditUpdate(data discord.SlashCommandInteractionData, event
278
294
formatType := FormatType (data .String ("format-type" ))
279
295
roleID := data .Snowflake ("role" )
280
296
proxy := data .String ("proxy" )
297
+ linkButton , linkButtonOk := data .OptBool ("link-button" )
281
298
282
299
sub , err := b .db .GetSubscriptionsByGuildSubreddit (* event .GuildID (), subreddit )
283
300
if errors .Is (err , ErrSubscriptionNotFound ) {
@@ -307,8 +324,11 @@ func (b *Bot) OnSubredditUpdate(data discord.SlashCommandInteractionData, event
307
324
if proxy == "" {
308
325
proxy = sub .RedditProxy
309
326
}
327
+ if ! linkButtonOk {
328
+ linkButton = sub .LinkButton
329
+ }
310
330
311
- if err = b .db .UpdateSubscription (sub .WebhookID , postType , formatType , roleID , proxy ); err != nil {
331
+ if err = b .db .UpdateSubscription (sub .WebhookID , postType , formatType , roleID , proxy , linkButton ); err != nil {
312
332
_ = event .CreateMessage (discord.MessageCreate {
313
333
Content : "Failed to update subscription: " + err .Error (),
314
334
Flags : discord .MessageFlagEphemeral ,
@@ -428,7 +448,7 @@ func (b *Bot) OnDiscordCallback(w http.ResponseWriter, r *http.Request) {
428
448
webhookID := snowflake .MustParse (wh ["id" ].(string ))
429
449
webhookToken := wh ["token" ].(string )
430
450
431
- if err = b .db . AddSubscription (Subscription {
451
+ if err = b .AddSubscription (Subscription {
432
452
Subreddit : setupState .Subreddit ,
433
453
Type : setupState .PostType ,
434
454
FormatType : setupState .FormatType ,
@@ -438,6 +458,7 @@ func (b *Bot) OnDiscordCallback(w http.ResponseWriter, r *http.Request) {
438
458
WebhookToken : webhookToken ,
439
459
RoleID : setupState .RoleID ,
440
460
RedditProxy : setupState .RedditProxy ,
461
+ LinkButton : setupState .LinkButton ,
441
462
}); err != nil {
442
463
_ , _ = b .Client .Rest ().UpdateInteractionResponse (setupState .Interaction .ApplicationID (), setupState .Interaction .Token (), discord.MessageUpdate {
443
464
Content : json .Ptr ("Failed to save subscription to the database: " + err .Error ()),
0 commit comments