Skip to content

Commit 39b4e3f

Browse files
committed
Add help menus for the rest of the commands
1 parent 7fdebbd commit 39b4e3f

File tree

4 files changed

+81
-4
lines changed

4 files changed

+81
-4
lines changed

src/api.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ pub(crate) fn slow_mode(args: Args) -> Result<()> {
7575
Ok(())
7676
}
7777

78+
pub(crate) fn slow_mode_help(args: Args) -> Result<()> {
79+
let help_string = format!(
80+
"
81+
Set slowmode on a channel
82+
```
83+
{command}
84+
```
85+
**Example:**
86+
```
87+
?slowmode #bot-usage 10
88+
```
89+
will set slowmode on the `#bot-usage` channel with a delay of 10 seconds.
90+
91+
**Disable slowmode:**
92+
```
93+
?slowmode #bot-usage 0
94+
```
95+
will disable slowmode on the `#bot-usage` channel.
96+
",
97+
command = "?slowmode {channel} {seconds}",
98+
);
99+
send_reply(&args, &help_string)?;
100+
Ok(())
101+
}
102+
78103
/// Kick a user from the guild.
79104
///
80105
/// Requires the kick members permission
@@ -95,3 +120,23 @@ pub(crate) fn kick(args: Args) -> Result<()> {
95120
}
96121
Ok(())
97122
}
123+
124+
pub(crate) fn kick_help(args: Args) -> Result<()> {
125+
let help_string = format!(
126+
"
127+
Kick a user from the guild
128+
```
129+
{command}
130+
```
131+
**Example:**
132+
```
133+
?kick @someuser
134+
```
135+
will kick a user from the guild.
136+
",
137+
command = "?kick {user}"
138+
);
139+
140+
send_reply(&args, &help_string)?;
141+
Ok(())
142+
}

src/ban.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Ban a user for a temporary amount of time
130130
```
131131
{command}
132132
```
133-
Example:
133+
**Example:**
134134
```
135135
?ban @someuser {hours} {reason}
136136
```

src/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn app() -> Result {
9191
// Tags
9292
cmds.add("?tags delete {key}", tags::delete);
9393
cmds.add("?tags create {key} value...", tags::post);
94-
cmds.add("?tags {key}", tags::get);
94+
cmds.add("?tag {key}", tags::get);
9595
cmds.add("?tags", tags::get_all);
9696
cmds.help("?tags", "A key value store", tags::help);
9797
}
@@ -109,16 +109,27 @@ fn app() -> Result {
109109
// Slow mode.
110110
// 0 seconds disables slowmode
111111
cmds.add("?slowmode {channel} {seconds}", api::slow_mode);
112+
cmds.help(
113+
"?slowmode",
114+
"Set slowmode on a channel",
115+
api::slow_mode_help,
116+
);
112117

113118
// Kick
114119
cmds.add("?kick {user}", api::kick);
120+
cmds.help("?kick", "Kick a user from the guild", api::kick_help);
115121

116122
// Ban
117123
cmds.add("?ban {user} {hours} reason...", ban::temp_ban);
118124
cmds.help("?ban", "Temporarily ban a user from the guild", ban::help);
119125

120126
// Post the welcome message to the welcome channel.
121127
cmds.add("?CoC {channel}", welcome::post_message);
128+
cmds.help(
129+
"?CoC",
130+
"Post the code of conduct message to a channel",
131+
welcome::help,
132+
);
122133

123134
let menu = main_menu(cmds.menu());
124135
cmds.add("?help", move |args: Args| {
@@ -143,11 +154,11 @@ fn main_menu(commands: &HashMap<&str, &str>) -> String {
143154
menu = commands
144155
.iter()
145156
.fold(menu, |mut menu, (base_cmd, description)| {
146-
menu += &format!("\t{cmd:<8}{desc}\n", cmd = base_cmd, desc = description);
157+
menu += &format!("\t{cmd:<12}{desc}\n", cmd = base_cmd, desc = description);
147158
menu
148159
});
149160

150-
menu += &format!("\t{help:<8}This menu\n", help = "?help");
161+
menu += &format!("\t{help:<12}This menu\n", help = "?help");
151162
menu += "\nType ?help command for more info on a command.";
152163
menu
153164
}

src/welcome.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,24 @@ pub(crate) fn assign_talk_role(cx: &Context, ev: &ReactionAddEvent) -> Result {
132132
}
133133
Ok(())
134134
}
135+
136+
pub(crate) fn help(args: Args) -> Result {
137+
let help_string = format!(
138+
"
139+
Post the welcome message to `channel`
140+
```
141+
{command}
142+
```
143+
**Example:**
144+
```
145+
?CoC #welcome
146+
147+
```
148+
will post the welcome message to the `channel` specified.
149+
",
150+
command = "?CoC {channel}"
151+
);
152+
153+
api::send_reply(&args, &help_string)?;
154+
Ok(())
155+
}

0 commit comments

Comments
 (0)