Commit 0f4f32fc authored by Timothy du Heaume's avatar Timothy du Heaume

prserve insertion order of react/role mappings

parent f39405ef
......@@ -16,3 +16,4 @@ serde_yaml = "^0.8"
serenity = "0.8.0"
simplelog = "^0.7.4"
guard = "0.5.0"
indexmap = "1.3.1"
extern crate indexmap;
use serde::Deserialize;
use serde_yaml;
use serenity::model::id;
use std::collections::HashMap;
use indexmap::IndexMap;
use std::fs;
lazy_static! {
......@@ -44,8 +45,10 @@ impl UccbotConfig {
}
}
pub type ReactRoleMap = IndexMap<String, id::RoleId>;
#[derive(Debug, Deserialize, Clone)]
pub struct ReactionMapping {
pub message: serenity::model::id::MessageId,
pub mapping: HashMap<String, id::RoleId>,
pub mapping: ReactRoleMap,
}
use crate::config::CONFIG;
use crate::config::{CONFIG, ReactRoleMap};
use crate::util::{get_react_from_string, get_string_from_react};
use serenity::{
client::Context,
......@@ -178,7 +178,7 @@ fn get_all_role_reaction_message(
ctx: &Context,
) -> Vec<(
Message,
&'static HashMap<String, serenity::model::id::RoleId>,
&'static ReactRoleMap,
)> {
let guild = ctx.http.get_guild(CONFIG.server_id).unwrap();
info!(" Find role-react message: guild determined");
......
Markdown is supported
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