Skip to content

Commit 4757d7c

Browse files
authored
Merge pull request #7 from scopeclient/ali/rustfmt-everything-and-create-util
rustfmt, resultext
2 parents be8fb43 + b49cff6 commit 4757d7c

File tree

17 files changed

+249
-252
lines changed

17 files changed

+249
-252
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/target
22
.vscode
3-
3+
.DS_Store
44
.direnv
55
.env

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/discord/src/channel/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ impl Channel for DiscordChannel {
2626
fn get_receiver(&self) -> broadcast::Receiver<Self::Message> {
2727
self.receiver.resubscribe()
2828
}
29-
}
29+
}

src/discord/src/client.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
use std::{collections::HashMap, rc::Rc, sync::Arc};
22

3-
use serenity::{all::{Context, EventHandler, GatewayIntents, Message}, async_trait, futures::SinkExt};
3+
use serenity::{
4+
all::{Context, EventHandler, GatewayIntents, Message},
5+
async_trait,
6+
futures::SinkExt,
7+
};
48
use tokio::sync::{broadcast, Mutex, RwLock};
59

6-
use crate::{message::{author::{DiscordMessageAuthor, DisplayName}, content::DiscordMessageContent, DiscordMessage}, snowflake::{self, Snowflake}};
10+
use crate::{
11+
message::{
12+
author::{DiscordMessageAuthor, DisplayName},
13+
content::DiscordMessageContent,
14+
DiscordMessage,
15+
},
16+
snowflake::{self, Snowflake},
17+
};
718

819
#[derive(Default)]
920
pub struct DiscordClient {
10-
channel_message_event_handlers: HashMap<Snowflake, Vec<broadcast::Sender<DiscordMessage>>>
21+
channel_message_event_handlers: HashMap<Snowflake, Vec<broadcast::Sender<DiscordMessage>>>,
1122
}
1223

1324
impl DiscordClient {
@@ -16,10 +27,7 @@ impl DiscordClient {
1627
let remote = RemoteDiscordClient(client.clone());
1728

1829
tokio::spawn(async {
19-
let mut client = serenity::Client::builder(token, GatewayIntents::all())
20-
.event_handler(remote)
21-
.await
22-
.expect("Error creating client");
30+
let mut client = serenity::Client::builder(token, GatewayIntents::all()).event_handler(remote).await.expect("Error creating client");
2331

2432
if let Err(why) = client.start().await {
2533
panic!("Client error: {why:?}");
@@ -45,7 +53,9 @@ impl EventHandler for RemoteDiscordClient {
4553
async fn message(&self, _: Context, msg: Message) {
4654
println!("Got message: {:?} {:?}", msg.channel_id, msg.content);
4755

48-
let snowflake = Snowflake { content: msg.channel_id.get() };
56+
let snowflake = Snowflake {
57+
content: msg.channel_id.get(),
58+
};
4959

5060
if let Some(vec) = self.0.read().await.channel_message_event_handlers.get(&snowflake) {
5161
for sender in vec {
@@ -55,13 +65,13 @@ impl EventHandler for RemoteDiscordClient {
5565
id: snowflake,
5666
author: DiscordMessageAuthor {
5767
display_name: DisplayName(msg.author.name.clone()),
58-
icon: msg.author.avatar_url().unwrap_or(msg.author.default_avatar_url())
68+
icon: msg.author.avatar_url().unwrap_or(msg.author.default_avatar_url()),
5969
},
6070
content: DiscordMessageContent {
61-
content: msg.content.clone()
62-
}
71+
content: msg.content.clone(),
72+
},
6373
});
6474
}
6575
}
6676
}
67-
}
77+
}

src/discord/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub mod message;
2-
pub mod snowflake;
31
pub mod channel;
42
pub mod client;
3+
pub mod message;
4+
pub mod snowflake;

src/discord/src/message/author.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ impl RenderOnce for DisplayName {
2424
fn render(self, _: &mut WindowContext) -> impl IntoElement {
2525
div().text_sm().child(self.0)
2626
}
27-
}
27+
}

src/discord/src/message/content.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ impl RenderOnce for DiscordMessageContent {
99
fn render(self, _: &mut WindowContext) -> impl IntoElement {
1010
self.content.clone()
1111
}
12-
}
12+
}

src/discord/src/message/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use scope_chat::message::Message;
55

66
use crate::snowflake::Snowflake;
77

8-
pub mod content;
98
pub mod author;
9+
pub mod content;
1010

1111
#[derive(Clone)]
1212
pub struct DiscordMessage {
@@ -28,4 +28,3 @@ impl Message for DiscordMessage {
2828
self.id.to_string()
2929
}
3030
}
31-

src/discord/src/snowflake.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#[derive(Clone, Hash, PartialEq, Eq, Copy)]
22
pub struct Snowflake {
3-
pub content: u64
3+
pub content: u64,
44
}
55

66
impl ToString for Snowflake {
77
fn to_string(&self) -> String {
88
self.content.to_string()
99
}
10-
}
10+
}

src/ui/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "scope"
33
version = "0.1.0"
44
edition = "2021"
55
authors = [
6-
"Rose Kodsi-Hall <rose@hall.ly>"
6+
"Rose Kodsi-Hall <rose@hall.ly>",
77
# Add yourself here if you contribute!
88
]
99
description = "discord client for power users"
@@ -13,9 +13,13 @@ repository = "https://github.com/scopeclient/scope"
1313
keywords = ["discord", "scope", "reticle"]
1414

1515
[dependencies]
16-
gpui = { git = "https://github.com/zed-industries/zed.git", version = "0.1.0", default-features = false, features = ["http_client", "font-kit"]}
17-
reqwest_client = { git = "https://github.com/zed-industries/zed.git", version = "0.1.0"}
16+
gpui = { git = "https://github.com/zed-industries/zed.git", version = "0.1.0", default-features = false, features = [
17+
"http_client",
18+
"font-kit",
19+
] }
20+
reqwest_client = { git = "https://github.com/zed-industries/zed.git", version = "0.1.0" }
1821
scope-chat = { version = "0.1.0", path = "../chat" }
22+
scope-util = { version = "0.1.0", path = "../util" }
1923
scope-backend-discord = { version = "0.1.0", path = "../discord" }
2024
dotenv = "0.15.0"
2125
env_logger = "0.11.5"

0 commit comments

Comments
 (0)