Finishes the AppState config hoisting (COR-12's groundwork was not present in the repo, so this ticket establishes it): AppState now carries guild_id, honeypot_channel_id, leetcode_channel_id, verified_role_id, logs_channel_id and weather_token, all parsed once in AppState::new(). A missing or unparseable id now produces one boot error naming every offending variable plus a pointer to .env.example, instead of a per-event .expect() panic (a data race under the multi-threaded runtime, since dotenv() calls the now-unsafe set_var). - main.rs: new fields, required_u64() collector, fail-fast with combined message. - events/message.rs: honeypot/create_leetcode_thread/on_message take &Data and read channel/guild ids from AppState; dropped dotenv() and env::var. - events/interaction_create.rs: deleted verified_role_id(); use data.state.verified_role_id. - commands/mods_only.rs: log_embed takes logs_channel_id: ChannelId; caller in message.rs passes data.state.logs_channel_id. - commands/weather.rs: WEATHER_TOKEN read once into AppState (non-fatal), passed to get_weather — required so the new CI grep guard can be clean. - .env.example: add LEETCODE_CHANNEL_ID. - .github/workflows/ci.yml: add "No environment reads outside main.rs" guard. grep -rn 'dotenv()\|env::var' src/ | grep -v '^src/main.rs:' now returns nothing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017XrE7F9ZuBWdQnS8CZvYDE |
||
|---|---|---|
| .github/workflows | ||
| src | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE | ||
| README.md | ||
DSEC Discord Bot
Deakin Software Engineering Club Discord Bot project. To encourage students to learn Rust and how to work in a practical and collaborative project.
Setup
Setup Rust
Installing Rustup will also install cargo
Linux & MacOS:
curl https://sh.rustup.rs -sSf | sh
Windows:
Download and run rustup-init.exe
Setup Discord Bot Profile on Discord Developers
Note: To contribute, you need to create your own Discord Bot profile and test it yourself in another server.
-
Open Discord Developers and click on "Get Started"
-
Create a New Application, with any name you like
-
Navigate to
Boton the left sidebar- Note down the
Token, the code of your bot will require it. - Enable all the Intents
Presence,Server Members,Message Content- This is required by Discord to ensure popular discord bots do not scrape server message contents without permission.
- Note down the
-
Generate a Discord Bot URL:
- Navigate to
OAuth2on the left sidebar - Scroll down to
OAuth2 URL Generator - Under Scopes, select
bot - Scroll down to
Bot Permissions - Select permissions, or later override it in the invite link.
- DSEC Bot's Permission integer is
4235288712703990.
- Copy the Generated URL, and invite your bot to your Discord server.
OR
https://discord.com/oauth2/authorize?client_id=DISCORD_BOT_ID&permissions=4235288712703990&integration_type=0&scope=bot
- Navigate to
Setup Discord Bot on your machine
Rust with Cargo
- Navigate to directory on your machine
git clone https://github.com/liyunze-coding/DSEC-Discord-Bot- Create
.envfile according to.env.example
- You can ask the committee (or Ryan) for the environment variables on Discord.
- Run
cargo run - You may need to reload Discord to see changes to slash commands.
Or Use Docker
- Make sure Docker engine is running.
- On Windows, open Docker Desktop.
- Run the commands
docker-compose build
docker-compose up
Rules
General Rules
- Follow DSEC Server Rules
- Follow Deakin Code of Conduct
- Follow Discord Terms of Services
Programming Rules
- Do not test in Production
- Do not write malicious code (unless you have obtained permission for white hat hacking)
- Do not spam pull requests
- Do not add your own code formatter, affecting the whole files you edit
To-do
- Membership verification command
- Unit information command
Information
What is Rust?
Rust is memory safe yet performant, making it the ideal programming language for systems programming.
C and C++ require developers to manage memory allocation, which can lead to memory unsafe programs.
Python, Java, C# and Go use the garbage collector so that developers don't need to manually manage memory, but can slow down the program significantly due to lack of low level control.
Rust takes a unique approach, by using an "ownership" and "borrowing" system to prevent memory bugs at compile time.
Hence, Rust is performant and memory safe (when you write it well).
Why Rust?
This is a good opportunity for students at Deakin to learn Rust.
At Deakin, Software Engineering, Computer Science and IT students mostly touch on high level languages such as Python, C# and low level languages such as C++.
More and more developer tools are being written in Rust, including Rolldown, Rspack, Tauri, SWC and many more (Ryan is a web developer, he's only aware of these tools written in Rust).
Rust has its own unique concepts and challenges such as the ownership model and the borrow checker. Its strict rules help prevent programming errors such as data races and memory leaks. The strict rules also help students learn how to think about writing efficient code coming from high level languages.