Skip to content

Trevrosa/abc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord bot written in rust

command structure

each module in src/commands must have a function with this signature:

async fn command(ctx: &Context, replyer: &Replyer/*, args: Args*/) -> Result<(), &'static str>

(where Context is serenity::client::Context, Message is utils::reply::Replyer, Args is utils::arg::Args.) The commented part is optional.

and, to support slash commands, contain the function:

fn register() -> CreateCommand

(where CreateCommand is serenity::builder::CreateCommand)

or be a module that re-exports other modules that conform to above.

note that new modules in src/commands must be reflected in crate::handlers::CommandHandler manually.

building

  • install songbird's dependencies (apt install build-essential autoconf automake libtool m4)
  • install mold
  • create file token at project root and put your bot token in
  • create file cat_apikey at project root and put your cat api key in
  • create file dog_apikey at project root and put your dog api key in
  • for the command getsong:
    • if you have a folder you want to put files larger than 10mb, set the ABC_SHARED_DIR environment variable to that folder.
    • if you have an external host url, create file external_host and put the base url in. if you don't, just touch external_host
    • get your spotify oauth credentials, put your client_id and secret in files spotify_clientid and spotify_secret respectively.
    • get your youtube oauth credentials, put your client_id and secret in files yt_clientid and yt_secret respectively.
  • install yt-dlp and make sure the binary is available in /usr/bin
  • if on windows, building might not work.
  • cargo build -r

notes

  • be careful using ctx.data.read(): it can deadlock since ctx.data is an instance of Arc<RwLock<..>>. a way to make these locks more clear is to use ctx.data.try_read(), and handle its result accordingly.
  • crate::utils::context::Ext includes extension methods to serenity::client::Context
  • crate::serenity_ctrlc is taken mostly from yehuthi/serenity_ctrlc (thanks!). i have changed it to make it work with serenity 0.12.1, and also provide ctx.data to handlers.
  • clippy.toml includes "forbidden" methods. these are only checked for when using clippy instead of cargo check
  • Cross.toml is used by cross to cross-compile
  • .cargo/config.toml makes cargo use clang to link. this makes it faster to compile, but can be omitted.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published