better dm
This commit is contained in:
parent
6f5bfdfd82
commit
faf95577da
|
@ -45,6 +45,8 @@ impl EventHandler for Handler {
|
||||||
let guild_id = if let Some(id) = msg.guild_id {
|
let guild_id = if let Some(id) = msg.guild_id {
|
||||||
id.to_string()
|
id.to_string()
|
||||||
} else {
|
} else {
|
||||||
|
let private_channel = discord_structure::Channel::new(author_name.clone(), msg.channel_id.to_string(), "dm".to_string());
|
||||||
|
sender.send(postman::Packet::Channel(private_channel)).expect("failed to send packet");
|
||||||
"dm".to_string()
|
"dm".to_string()
|
||||||
};
|
};
|
||||||
let discord_message = discord_structure::Message::new(msg.id.to_string(), msg.channel_id.to_string(), guild_id, author_name, msg.content.clone(), msg.timestamp.to_rfc2822());
|
let discord_message = discord_structure::Message::new(msg.id.to_string(), msg.channel_id.to_string(), guild_id, author_name, msg.content.clone(), msg.timestamp.to_rfc2822());
|
||||||
|
|
|
@ -15,6 +15,21 @@ impl Guild {
|
||||||
channels: vec![],
|
channels: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_channel(&mut self, channel: Channel) {
|
||||||
|
let mut already_exist = false;
|
||||||
|
|
||||||
|
for existing_channel in self.channels.clone() {
|
||||||
|
if existing_channel.id != channel.id {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
already_exist = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !already_exist {
|
||||||
|
self.channels.insert(0, channel.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone)]
|
#[derive(PartialEq, Clone)]
|
||||||
|
|
|
@ -86,8 +86,7 @@ impl eframe::App for Jiji {
|
||||||
if self.guilds[i].id != channel.guild_id {
|
if self.guilds[i].id != channel.guild_id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
self.guilds[i].channels.push(channel.clone());
|
self.guilds[i].add_channel(channel.clone());
|
||||||
println!("gui : channel added to '{}'", self.guilds[i].name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
postman::Packet::Message(message) => {
|
postman::Packet::Message(message) => {
|
||||||
|
|
Loading…
Reference in a new issue