this is the translation of my typescript discord bot, it will be same but more stable
well, i m just newbie programer and my last bot is just work, although sometime it produce ghost bug since long ago i dont know how to do thing properly
- easy to maintain, error is handled properly and unit tested
- no dependency issue, using compiled language will produce exutable
- easy to develope, since its more readable now?
- faster? using rust will definitely get you faster?
- added more feature
- easy to setup, download the release, edit config.json and run exutable
- i want learn rust, so this is my playground
- need to translate huge amount of code
- using main dependency
serenity
will be hard since its not really documented yet - compile time is depresing
- literally no helper,
serenity
comunity is still so small, it will be hard if you face a problem - still using third-party dependency for
asynchronous
, this will be no problem i guess
100% work in progress
- initialize project
- basic
serenity
handling - sqlx interface binding
- image processing binding
- setup dependency tree
- setup easy code framework to handle
- setup unit testing
- setup github action
- setup token and gateway
- setup ready event handler
- basic slah command runner and register
- register all slash command
- unhandled error send to discord channel
- implement button push create and handler
- implement basic embed rich builder
- modal builder for register command
- handle modal interaction
- implement auto complete for guild command
- create guide embed command
- add emojis
- create custom build command
- role specific command
- get attachment and send attachment
- make bind command easier
- change guild interface command
- add cheater scan command
- make more beautiful bounty board
- install
Sqlx
crate - make .sql file for first initialize and update
- make command to execute .sql init
- handle all database related (register,bounty,gacha)
- error handling
- make testing database (may or may not)
- make update command to extend the bot
- install
Image
crate - learn basic ROI and IO
- setup image processing for member join event handler
- setup image processing for gacha pull
- setup image processing for bounty
- cached sahred process
there is some
- download the release
- extract the zip
- fill out
config.json
- run the exutable
if you want build or edit from source, or the exutable isnt working on release
you need following tool isntalled on your OS
- Rust
- cargo
- git
- curl
for windows you need to have linker
to build rust project
detail of how to install rust and cargo is covered in rust book here
- download any release you want (its already contain source code)
- extract the zip
- build release the source and place it on main folder
forMacOs
orlinux
cargo build --release
cp ./target/release/rain-bot .
for windows
cargo build --release
copy ./target/release/rain-bot.exe .
- edit the
config.json
file - run the exutable
well if you want to stay upto date, you can follow this step
- clone the repository
- build release, place the exutable on main then rename example file
forMacOs
orlinux
cargo build --release
cp ./target/release/rain-bot .
mv ./config.json.example config.json
for windows
cargo build --release
copy ./target/release/rain-bot.exe .
ren ./config.json.example config.json
- edit
config.json
file - run the exutable
most is not implemented yet so you can leave it as it is except some few
i will mark what you need to cahnge on the pointer <-
comment
just dont fill the actual file with my comment
{
"discord": {
"token":"your token",
"prefix":"%",
"author_id":455622761168109569
},
"postgress": {
"user":"postgres",
"host":"localhost",
"password":"",
"port":5432,
"database":"erupe"
},
"mhfz_config": {
"account_creation":true, <- set this according to your erupe client config
"sending_log":false <- you need to run bash script to create log and move it to bot folder named ./log.txt
},
"bot_config": { <- bot config to be added on server
"gacha":true,
"server_market":true
},
"log_channel": {
"err_channel":1031774270512169070, <- channel to log bot error (dont make it private)
"account_channel":1031774270512169070, <- channel to log user account created
"transfer_channel":1031774270512169070, <- channel to judge player save file (make it private)
"info_channel":1031774270512169070, <- channel for server monitor
"info_channel_msg":1070671548408664124, <- message in info channel id to be edited continiusly
"erupe_channel":1031774270512169070, <- channel to dump log file
"market_channel":1031774270512169070, <- you can ignore this if server_market is false
"market_channel_msg":1076848380971589634, <- same as above
},
"server_role":{
"admin_role":1031595216538452038,
"register_role":1031595216538452038,
"judge_role":1017643913667936318, <- role pinged on transfer savefile
"maintainer_role":1017643913667936318 <- role pinged on server crash
}
}
there will be upcoming Rain Moderation App
for further customzation (mainly for event and image editing)
the implemented command right now
- Admin Command
/interface
to send register and send save button/config
to change bot config/market
to send item to player, can be with or without bounty coin/purge
to delete all player binded data with discord
- Binded Command
/card
to show user hunter statusApp>Card
to check other user hunter status/dm_save
to send user their backup save file on dm/transfer
for transfer save file, save need to be approved by admin and have cd
- Register Command
/switch
to switch their main character for event/change_password
to change password/check
to check own username and id/create
to create blank account on MHFZ/bind
to bind existing account on MHFZ if autocreation is enabled
- Gacha Command
/pull
to perform gacha command if gacha enabled
- Market Command
/stall
for player to buy item in stall set in config if server market enabled
- Admin Only Message Command
<Prefix>query
add codeblock affterward to query your sql code on server database and get the decoded result<Prefix>excute
add codeblock affterward to execute your code on server database
- Some Usefull Message Command
<prefix>ping
to see discord connection ping,postgres conn ping, and json parsing file system speed<prefix>test
to show test embed (you can use this to set up bot config,copy its message id and channel id)
senpai
branch is used for release candidate and you can clone from there
kohai
branch is used for development, you can pull request there
sensei
branch is used for release, solely for building exutable and github action
the library is only for procedural macro attributes, most of macro will need 2 attribute, one is integer for cooldown,
and second is boolean for defer (if you think command takes more than 3 sec), the macro only accept function with arguments,
Mybundle
trait, so you can use SlashBundle
,ComponentBundle
, ModalBundle
or the trait itself if you want compount command
the macro also only accept return type Result<(),MyErr>
, the macro will produce the public async function with name
discord_<function name>
with no return type, and you can use it on event handler.