Skip to content
Snippets Groups Projects
Commit b0048da2 authored by Timothy du Heaume's avatar Timothy du Heaume
Browse files

prserve insertion order of react/role mappings

parent f39405ef
No related merge requests found
Pipeline #155 failed with stages
...@@ -16,3 +16,4 @@ serde_yaml = "^0.8" ...@@ -16,3 +16,4 @@ serde_yaml = "^0.8"
serenity = "0.8.0" serenity = "0.8.0"
simplelog = "^0.7.4" simplelog = "^0.7.4"
guard = "0.5.0" guard = "0.5.0"
indexmap = { version = "1.3.1", features = ["serde-1"] }
use serde::Deserialize; use serde::Deserialize;
use serde_yaml; use serde_yaml;
use serenity::model::id; use serenity::model::id;
use std::collections::HashMap; use indexmap::IndexMap;
use std::fs; use std::fs;
lazy_static! { lazy_static! {
...@@ -44,8 +44,10 @@ impl UccbotConfig { ...@@ -44,8 +44,10 @@ impl UccbotConfig {
} }
} }
pub type ReactRoleMap = IndexMap<String, id::RoleId>;
#[derive(Debug, Deserialize, Clone)] #[derive(Debug, Deserialize, Clone)]
pub struct ReactionMapping { pub struct ReactionMapping {
pub message: serenity::model::id::MessageId, pub message: serenity::model::id::MessageId,
pub mapping: HashMap<String, id::RoleId>, pub mapping: ReactRoleMap,
} }
...@@ -4,6 +4,7 @@ extern crate lazy_static; ...@@ -4,6 +4,7 @@ extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate simplelog; extern crate simplelog;
extern crate indexmap;
#[macro_use] extern crate guard; #[macro_use] extern crate guard;
use simplelog::*; use simplelog::*;
use std::fs::{read_to_string, File}; use std::fs::{read_to_string, File};
......
use crate::config::CONFIG; use crate::config::{CONFIG, ReactRoleMap};
use crate::util::{get_react_from_string, get_string_from_react}; use crate::util::{get_react_from_string, get_string_from_react};
use serenity::{ use serenity::{
client::Context, client::Context,
...@@ -178,7 +178,7 @@ fn get_all_role_reaction_message( ...@@ -178,7 +178,7 @@ fn get_all_role_reaction_message(
ctx: &Context, ctx: &Context,
) -> Vec<( ) -> Vec<(
Message, Message,
&'static HashMap<String, serenity::model::id::RoleId>, &'static ReactRoleMap,
)> { )> {
let guild = ctx.http.get_guild(CONFIG.server_id).unwrap(); let guild = ctx.http.get_guild(CONFIG.server_id).unwrap();
info!(" Find role-react message: guild determined"); info!(" Find role-react message: guild determined");
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment