corrected versioning. updated readme. removed client_id field from environment. now sends guild counts by shard. tagged info message with bot version
This commit is contained in:
parent
697d8aa9f1
commit
50fb419a19
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1338,7 +1338,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "soundfx-rs"
|
name = "soundfx-rs"
|
||||||
version = "0.1.0"
|
version = "1.0.1-rc.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
12
Cargo.toml
12
Cargo.toml
@ -1,13 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "soundfx-rs"
|
name = "soundfx-rs"
|
||||||
version = "0.1.0"
|
version = "1.0.1-rc.3"
|
||||||
authors = ["jude-lafitteIII <judewrs@gmail.com>"]
|
authors = ["jude-lafitteIII <judewrs@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serenity = {git = "https://github.com/Lakelezz/serenity", branch = "await", features = ["voice", "collector"]}
|
serenity = { git = "https://github.com/Lakelezz/serenity", branch = "await", features = ["voice", "collector"] }
|
||||||
sqlx = {version = "0.3.5", default-features = false, features = ["runtime-tokio", "macros", "mysql", "bigdecimal"]}
|
sqlx = { version = "0.3.5", default-features = false, features = ["runtime-tokio", "macros", "mysql", "bigdecimal"] }
|
||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
tokio = {version = "0.2.19", features = ["fs", "sync", "process", "io-util"]}
|
tokio = { version = "0.2", features = ["fs", "sync", "process", "io-util"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4"
|
||||||
reqwest = "0.10.6"
|
reqwest = "0.10"
|
||||||
|
@ -6,7 +6,7 @@ efficient and robust package. SoundFX 2 is as asynchronous as it can get, and ru
|
|||||||
|
|
||||||
### Building
|
### Building
|
||||||
|
|
||||||
Use the Cargo.toml file to build it. Simple as. Don't need any shit like MySQL libs and stuff because SQLx includes its
|
Use the Cargo.toml file to build it. Simple as. Don't need anything like MySQL libs and stuff because SQLx includes its
|
||||||
own pure Rust one. Needs Rust 1.43+
|
own pure Rust one. Needs Rust 1.43+
|
||||||
|
|
||||||
### Running & Config
|
### Running & Config
|
||||||
@ -22,4 +22,3 @@ Config options:
|
|||||||
* `PATREON_GUILD`- specifies the ID of the guild being used for Patreon benefits
|
* `PATREON_GUILD`- specifies the ID of the guild being used for Patreon benefits
|
||||||
* `PATREON_ROLE`- specifies the role being checked for Patreon benefits
|
* `PATREON_ROLE`- specifies the role being checked for Patreon benefits
|
||||||
* `CACHING_LOCATION`- specifies the location in which to cache the audio files (defaults to `/tmp/`)
|
* `CACHING_LOCATION`- specifies the location in which to cache the audio files (defaults to `/tmp/`)
|
||||||
* `CLIENT_ID`- specifies the ID of the client for mention commands
|
|
||||||
|
34
src/main.rs
34
src/main.rs
@ -22,7 +22,7 @@ use serenity::{
|
|||||||
model::{
|
model::{
|
||||||
channel::{Channel, Message},
|
channel::{Channel, Message},
|
||||||
guild::Guild,
|
guild::Guild,
|
||||||
id::{GuildId, RoleId, UserId},
|
id::{GuildId, RoleId},
|
||||||
voice::VoiceState,
|
voice::VoiceState,
|
||||||
},
|
},
|
||||||
prelude::{Mutex as SerenityMutex, *},
|
prelude::{Mutex as SerenityMutex, *},
|
||||||
@ -38,6 +38,8 @@ use dotenv::dotenv;
|
|||||||
|
|
||||||
use tokio::{sync::RwLock, time};
|
use tokio::{sync::RwLock, time};
|
||||||
|
|
||||||
|
use serenity::http::Http;
|
||||||
|
use serenity::utils::shard_id;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
env,
|
env,
|
||||||
@ -244,13 +246,19 @@ struct Handler;
|
|||||||
|
|
||||||
#[serenity::async_trait]
|
#[serenity::async_trait]
|
||||||
impl EventHandler for Handler {
|
impl EventHandler for Handler {
|
||||||
async fn guild_create(&self, ctx: Context, _guild: Guild, is_new: bool) {
|
async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) {
|
||||||
if is_new {
|
if is_new {
|
||||||
if let Ok(token) = env::var("DISCORDBOTS_TOKEN") {
|
if let Ok(token) = env::var("DISCORDBOTS_TOKEN") {
|
||||||
let guild_count = ctx.cache.guild_count().await;
|
let guild_count = ctx.cache.guild_count().await as u64;
|
||||||
|
let shard_count = ctx.cache.shard_count().await;
|
||||||
|
|
||||||
let mut hm = HashMap::new();
|
let mut hm = HashMap::new();
|
||||||
hm.insert("server_count", guild_count);
|
hm.insert("server_count", guild_count);
|
||||||
|
hm.insert(
|
||||||
|
"shard_id",
|
||||||
|
shard_id(guild.id.as_u64().to_owned(), shard_count),
|
||||||
|
);
|
||||||
|
hm.insert("shard_count", shard_count);
|
||||||
|
|
||||||
let client = ctx
|
let client = ctx
|
||||||
.data
|
.data
|
||||||
@ -423,6 +431,12 @@ async fn dispatch_error_hook(ctx: &Context, msg: &Message, error: DispatchError)
|
|||||||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
dotenv()?;
|
dotenv()?;
|
||||||
|
|
||||||
|
let token = env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment");
|
||||||
|
|
||||||
|
let http = Http::new_with_token(&token);
|
||||||
|
|
||||||
|
let logged_in_id = http.get_current_user().await?.id;
|
||||||
|
|
||||||
let voice_guilds = Arc::new(RwLock::new(HashMap::new()));
|
let voice_guilds = Arc::new(RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
let framework = StandardFramework::new()
|
let framework = StandardFramework::new()
|
||||||
@ -466,11 +480,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
.allow_dm(false)
|
.allow_dm(false)
|
||||||
.ignore_bots(true)
|
.ignore_bots(true)
|
||||||
.ignore_webhooks(true)
|
.ignore_webhooks(true)
|
||||||
.on_mention(
|
.on_mention(Some(logged_in_id))
|
||||||
env::var("CLIENT_ID")
|
|
||||||
.and_then(|val| Ok(UserId(val.parse::<u64>().expect("CLIENT_ID not valid"))))
|
|
||||||
.ok(),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.group(&ALLUSERS_GROUP)
|
.group(&ALLUSERS_GROUP)
|
||||||
.group(&ROLEMANAGEDUSERS_GROUP)
|
.group(&ROLEMANAGEDUSERS_GROUP)
|
||||||
@ -663,22 +673,26 @@ async fn help(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
|
|||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
async fn info(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
|
async fn info(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
|
||||||
|
let current_user = ctx.cache.current_user().await;
|
||||||
|
|
||||||
msg.channel_id.send_message(&ctx, |m| m
|
msg.channel_id.send_message(&ctx, |m| m
|
||||||
.embed(|e| e
|
.embed(|e| e
|
||||||
.title("Info")
|
.title("Info")
|
||||||
.color(THEME_COLOR)
|
.color(THEME_COLOR)
|
||||||
|
.footer(|f| f
|
||||||
|
.text(concat!(env!("CARGO_PKG_NAME"), " ver ", env!("CARGO_PKG_VERSION"))))
|
||||||
.description(format!("Default prefix: `?`
|
.description(format!("Default prefix: `?`
|
||||||
|
|
||||||
Reset prefix: `<@{0}> prefix ?`
|
Reset prefix: `<@{0}> prefix ?`
|
||||||
|
|
||||||
Invite me: https://discordapp.com/oauth2/authorize?client_id={0}&scope=bot&permissions=36703232
|
Invite me: https://discordapp.com/oauth2/authorize?client_id={1}&scope=bot&permissions=36703232
|
||||||
|
|
||||||
**Welcome to SoundFX!**
|
**Welcome to SoundFX!**
|
||||||
Developer: <@203532103185465344>
|
Developer: <@203532103185465344>
|
||||||
Find me on https://discord.jellywx.com/ and on https://github.com/JellyWX :)
|
Find me on https://discord.jellywx.com/ and on https://github.com/JellyWX :)
|
||||||
|
|
||||||
**An online dashboard is available!** Visit https://soundfx.jellywx.com/dashboard
|
**An online dashboard is available!** Visit https://soundfx.jellywx.com/dashboard
|
||||||
There is a maximum sound limit per user. This can be removed by donating at https://patreon.com/jellywx", env::var("CLIENT_ID").unwrap())))).await?;
|
There is a maximum sound limit per user. This can be removed by donating at https://patreon.com/jellywx", current_user.name, current_user.id.as_u64())))).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user