-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd73251
commit 3b3a84b
Showing
10 changed files
with
657 additions
and
290 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
use serenity::framework::standard::macros::command; | ||
use serenity::framework::standard::CommandResult; | ||
use serenity::model::prelude::*; | ||
use serenity::prelude::*; | ||
use crate::{Context, Error}; | ||
|
||
#[command] | ||
async fn discord(ctx: &Context, msg: &Message) -> CommandResult { | ||
msg.reply(&ctx, "https://discord.gg/CsqAfs9CnM").await?; | ||
#[poise::command(prefix_command, slash_command)] | ||
pub async fn discord(ctx: Context<'_>) -> Result<(), Error> { | ||
ctx.reply("https://discord.gg/CsqAfs9CnM").await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,28 @@ | ||
/* | ||
modified by hahayupgit 2024/4/9 | ||
desc: added ability to return webpage of inputted argument | ||
*/ | ||
|
||
use serenity::framework::standard::macros::command; | ||
use serenity::framework::standard::CommandResult; | ||
use serenity::model::prelude::*; | ||
use serenity::prelude::*; | ||
|
||
#[command] | ||
#[aliases("gs")] | ||
async fn game_support(ctx: &Context, msg: &Message) -> CommandResult { | ||
use reqwest::StatusCode; | ||
use crate::{Context, Error}; | ||
|
||
#[poise::command(prefix_command, slash_command, aliases("gs"))] | ||
pub async fn game_support(ctx: Context<'_>, | ||
#[description = "Game Name"] game_name: Option<String>) -> Result<(), Error> { | ||
// String containing default response | ||
let mut site = String::from("https://docs.getwhisky.app/game-support/"); | ||
|
||
// command stripped of leading and trailing whitespace | ||
let mut message = msg.content.trim().to_string(); | ||
match game_name { | ||
Some(name) => { | ||
site.push_str(&name); | ||
|
||
// if command is only "~gs" or "~game_support", reply with default response | ||
if message == "~gs" || message == "~game_support" { | ||
msg.reply(&ctx, site).await?; | ||
} | ||
let resp = reqwest::get(site.clone()).await?; | ||
|
||
// if command has arguments | ||
else { | ||
|
||
// determine which command was said & remove command given | ||
if message.contains("~gs") { | ||
message = message.replace("~gs ", ""); | ||
} | ||
else { | ||
message = message.replace("~game_support ", ""); | ||
if resp.status() != StatusCode::NOT_FOUND { | ||
ctx.reply(site).await?; | ||
} else { | ||
ctx.reply("Hmm, seems that game isn't in our docs.").await?; | ||
} | ||
}, | ||
None => { | ||
ctx.reply(site).await?; | ||
} | ||
|
||
// concatenate the argument to the original default response & reply | ||
site.push_str(&message); | ||
msg.reply(&ctx, site).await?; | ||
|
||
/* | ||
NOTE: this method does not have any checks for | ||
URLs that are incorrect. this should not pose | ||
any security threats, however may make it harder | ||
for people who don't know the exact URL of longer games | ||
(i.e. Star Wars Jedi: Fallen Order being sw-fallen-order | ||
or Geometry Wars 3: Dimensions Evolved being gw3-dimensions-evolved). | ||
if i was a better developer, i'd figure out how to handle | ||
this. but i'm not, so i may return to this in a future change. | ||
- hahayupgit 2024/4/9 | ||
*/ | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
use serenity::framework::standard::macros::command; | ||
use serenity::framework::standard::CommandResult; | ||
use serenity::model::prelude::*; | ||
use serenity::prelude::*; | ||
use crate::{Context, Error}; | ||
|
||
#[command] | ||
async fn github(ctx: &Context, msg: &Message) -> CommandResult { | ||
msg.reply(&ctx, "https://github.com/Whisky-App/Whisky").await?; | ||
#[poise::command(prefix_command, slash_command)] | ||
pub async fn github(ctx: Context<'_>) -> Result<(), Error> { | ||
ctx.reply("https://github.com/Whisky-App/Whisky").await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
use serenity::framework::standard::macros::command; | ||
use serenity::framework::standard::CommandResult; | ||
use serenity::model::prelude::*; | ||
use serenity::prelude::*; | ||
use crate::{Context, Error}; | ||
|
||
#[command] | ||
async fn ping(ctx: &Context, msg: &Message) -> CommandResult { | ||
msg.reply(&ctx, "Pong! ~").await?; | ||
#[poise::command(prefix_command, slash_command)] | ||
pub async fn ping(ctx: Context<'_>) -> Result<(), Error> { | ||
ctx.reply("Pong! ~").await?; | ||
Ok(()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
use serenity::framework::standard::macros::command; | ||
use serenity::framework::standard::CommandResult; | ||
use serenity::model::prelude::*; | ||
use serenity::prelude::*; | ||
use crate::{Context, Error}; | ||
|
||
#[command] | ||
async fn website(ctx: &Context, msg: &Message) -> CommandResult { | ||
msg.reply(&ctx, "https://getwhisky.app/").await?; | ||
#[poise::command(prefix_command, slash_command)] | ||
pub async fn website(ctx: Context<'_>) -> Result<(), Error> { | ||
ctx.reply("https://getwhisky.app/").await?; | ||
Ok(()) | ||
} |
Oops, something went wrong.