1
+ using System . Collections . Generic ;
1
2
using System . Threading . Tasks ;
2
3
using Discord ;
3
4
using Discord . WebSocket ;
5
+ using Gommon ;
4
6
using Qmmands ;
5
7
using Volte . Core . Entities ;
6
8
using Volte . Services ;
@@ -18,39 +20,57 @@ public sealed class StarboardModule : VolteModule
18
20
19
21
[ Command ( "Channel" , "Ch" ) ]
20
22
[ Description ( "Sets the channel to be used by starboard when a message is starred." ) ]
21
- public Task < ActionResult > ChannelAsync ( SocketTextChannel channel )
23
+ public Task < ActionResult > ChannelAsync (
24
+ [ Description ( "The channel to be used by Starboard." ) ] SocketTextChannel channel )
22
25
{
23
- Context . Modify ( data =>
24
- {
25
- data . Configuration . Starboard . StarboardChannel = channel . Id ;
26
- } ) ;
26
+ Context . Modify ( data => data . Configuration . Starboard . StarboardChannel = channel . Id ) ;
27
27
return Ok ( $ "Successfully set the starboard channel to { MentionUtils . MentionChannel ( channel . Id ) } .") ;
28
28
}
29
29
30
30
[ Command ( "Amount" , "Count" ) ]
31
31
[ Description ( "Sets the amount of stars required on a message for it to be posted to the Starboard." ) ]
32
- public Task < ActionResult > AmountAsync ( int amount )
32
+ public Task < ActionResult > AmountAsync (
33
+ [ Description ( "The desired star count threshold before posting it in the starboard channel." ) ] int amount )
33
34
{
34
35
if ( amount < 1 )
35
- {
36
36
return BadRequest ( "Amount must be larger than zero." ) ;
37
- }
37
+
38
+
39
+ Context . Modify ( data => data . Configuration . Starboard . StarsRequiredToPost = amount ) ;
40
+
41
+ return Ok ( $ "Set the amount of stars required to be posted as a starboard message to **{ amount } **.") ;
42
+ }
38
43
44
+ [ Command ( "Setup" ) ]
45
+ [ Description ( "A one-off command that creates a channel for Starboard, with read-only permissions for everyone, and enables the starboard." ) ]
46
+ public async Task < ActionResult > SetupAsync (
47
+ [ Description ( "The name for the Starboard channel that will be created." ) , Remainder ] string channelName = "starboard" )
48
+ {
49
+ var channel = await Context . Guild . CreateTextChannelAsync ( channelName . Replace ( " " , "-" ) , props =>
50
+ {
51
+ props . CategoryId = Context . Channel . CategoryId ;
52
+ props . PermissionOverwrites = new List < Overwrite >
53
+ {
54
+ new Overwrite ( Context . Guild . EveryoneRole . Id , PermissionTarget . Role ,
55
+ new OverwritePermissions ( viewChannel : PermValue . Allow , sendMessages : PermValue . Deny ) )
56
+ } ;
57
+ } ) ;
58
+
39
59
Context . Modify ( data =>
40
60
{
41
- data . Configuration . Starboard . StarsRequiredToPost = amount ;
61
+ data . Configuration . Starboard . Enabled = true ;
62
+ data . Configuration . Starboard . StarboardChannel = channel . Id ;
42
63
} ) ;
43
- return Ok ( $ "Set the amount of stars required to be posted as a starboard message to **{ amount } **.") ;
64
+
65
+ return Ok ( $ "Successfully configured the Starboard functionality, and any starred messages will go to { channel . Mention } .") ;
44
66
}
45
67
46
68
[ Command ( "Enable" ) ]
47
69
[ Description ( "Enable or disable the Starboard in this guild." ) ]
48
- public Task < ActionResult > EnableAsync ( bool enabled )
70
+ public Task < ActionResult > EnableAsync (
71
+ [ Description ( "Whether or not to enable or disable the Starboard." ) ] bool enabled )
49
72
{
50
- Context . Modify ( data =>
51
- {
52
- data . Configuration . Starboard . Enabled = enabled ;
53
- } ) ;
73
+ Context . Modify ( data => data . Configuration . Starboard . Enabled = enabled ) ;
54
74
return Ok (
55
75
enabled ? "Enabled the Starboard in this Guild." : "Disabled the Starboard in this Guild." ) ;
56
76
}
0 commit comments