Draft
Conversation
…he configured server ID.
Member
Author
|
This is an attempt at #8, where we can connect and get meaningful data. I can see the username of messages that are entered in the chat, but not the message contents themselves. Might be a permission thing? |
| loop { | ||
| match connection.recv_event() { | ||
| Ok(Event::MessageCreate(message)) => { | ||
| println!("{} says: {}", message.author.name, message.content); |
Collaborator
There was a problem hiding this comment.
Can we bring in a logging library here?
I'd prefer a structured logging approach that we can hook into various tracing/aggregation tools
| match connection.recv_event() { | ||
| Ok(Event::MessageCreate(message)) => { | ||
| println!("{} says: {}", message.author.name, message.content); | ||
| if message.content == "!test" { |
Collaborator
There was a problem hiding this comment.
np: I'd prefer a constant for these values
// At the top of file
static TEST_CMD: &str = "!test";
Comment on lines
+81
to
+84
| fn get_server_id(config: Config) -> u64 { | ||
| let num = u64::from_str(config.server_id.as_str()).unwrap(); | ||
| return num; | ||
| } |
Collaborator
There was a problem hiding this comment.
This function is pretty small, maybe just do this in main until we have more config values to extract?
| fn main() { | ||
| let cfg = Config::from_env_and_args(); | ||
| let discord = get_discord(cfg.bot_token.as_str()); | ||
| let server_id = ServerId(self::get_server_id(cfg)); |
Collaborator
There was a problem hiding this comment.
Did you add the function so that you could wrap the return with ServerId?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an example
.envfile, that when properly configured, will pull the name of the server for the configured SERVER_ID. Also adds a test for the new config variable.