-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
7750ed2
commit aea0f51
Showing
11 changed files
with
238 additions
and
192 deletions.
There are no files selected for viewing
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,4 +1,3 @@ | ||
version: '3.3' | ||
services: | ||
mongo: | ||
image: mongo:5.0.10 | ||
|
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
30 changes: 30 additions & 0 deletions
30
trackscape-discord-bot/src/commands/manually_run_wom_sync_command.rs
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::database::BotMongoDb; | ||
use serenity::builder::CreateCommand; | ||
use serenity::client::Context; | ||
use serenity::model::prelude::Permissions; | ||
use trackscape_discord_shared::database::guilds_db::RegisteredGuildModel; | ||
use trackscape_discord_shared::jobs::wom_guild_sync_logic::sync_wom_by_guild; | ||
|
||
pub fn register() -> CreateCommand { | ||
CreateCommand::new("sync") | ||
.description("If WOM is connected it syncs between Trackscape and WOM.") | ||
.default_member_permissions(Permissions::MANAGE_GUILD) | ||
} | ||
|
||
pub async fn run(_ctx: &Context, db: &BotMongoDb, guild_id: u64) -> Option<String> { | ||
match db.guilds.get_by_guild_id(guild_id).await { | ||
Ok(saved_guild) => { | ||
let saved_guild = saved_guild.unwrap_or(RegisteredGuildModel::new(guild_id)); | ||
match saved_guild.wom_id { | ||
Some(_) => { | ||
sync_wom_by_guild(&saved_guild, db).await; | ||
None | ||
} | ||
None => Some("Please set your WOM group's id first with /wom ".to_string()), | ||
} | ||
} | ||
Err(_) => { | ||
Some("No saved guild was found. Please try adding and removing the bot".to_string()) | ||
} | ||
} | ||
} |
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
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,5 +1,4 @@ | ||
use crate::database::{BotMongoDb, MongoDb}; | ||
|
||
use redis::{Connection, RedisResult}; | ||
use std::env; | ||
|
||
|
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
Oops, something went wrong.