mirror of
https://github.com/osmarks/autobotrobot
synced 2025-01-03 04:10:27 +00:00
Fortune command
This commit is contained in:
parent
557fa14ec3
commit
1546889240
@ -32,11 +32,12 @@ pub fn main() {
|
||||
.case_insensitivity(true)
|
||||
.on_mention(true))
|
||||
.help(help_commands::with_embeds)
|
||||
.before(|_context, message, _command| { println!("> {}", message.content); true })
|
||||
.before(|_context, message, _command| { eprintln!("> {}", message.content); true })
|
||||
.command("ping", |c| c.cmd(ping).desc("Says Pong.").known_as("test"))
|
||||
.command("search", |c| c.cmd(search).desc("Executes a search using DuckDuckGo.").known_as("ddg"))
|
||||
.command("eval", |c| c.cmd(eval).desc("Evaluates an arithmetic expression.").known_as("calc"))
|
||||
.command("exec", |c| c.cmd(exec).desc("Executes code passed in codeblock with language set via Coliru. Supported languages: `python`, `shell`, `haskell`, `lua`."))
|
||||
.command("fortune", |c| c.cmd(fortune).desc("Displays a random `fortune`."))
|
||||
.command("eval-polish", |c| c.cmd(eval_polish).desc("Evaluates a Polish-notation arithmetic expression.")));
|
||||
|
||||
if let Err(why) = client.start() {
|
||||
@ -152,6 +153,12 @@ command!(exec(_context, message) {
|
||||
}?;
|
||||
});
|
||||
|
||||
command!(fortune(_context, message) {
|
||||
let output = std::process::Command::new("fortune").output()?.stdout;
|
||||
let output = String::from_utf8(output)?;
|
||||
message.channel_id.send_message(|m| m.content(output))?;
|
||||
});
|
||||
|
||||
// BELOW THIS LINE BE DRAGONS
|
||||
|
||||
struct SearchResult {
|
||||
|
Loading…
Reference in New Issue
Block a user