Skip to content

Commit

Permalink
W.I.P., upgrading dependencies, uncompilable
Browse files Browse the repository at this point in the history
  • Loading branch information
DoggySazHi committed Jan 19, 2024
1 parent 6100144 commit 7039a90
Show file tree
Hide file tree
Showing 22 changed files with 303 additions and 386 deletions.
48 changes: 25 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,55 +1,57 @@
[package]
name = "cow"
description = "moo"
version = "0.2.50"
version = "0.2.51"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# JSON parsing
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0.87"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111"
# HTML parsing
scraper = "0.18.1"
# Async
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread"] }
# Logging
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
tracing-appender = "0.2.2"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-appender = "0.2.3"
# Time
chrono = "0.4.22"
chrono = "0.4.31"
# SQL Server
bb8 = "0.8.0"
bb8 = "0.8.1"
bb8-tiberius = "0.15.0"
# Decimal data type (for SQL Server)
rust_decimal = "1.26.1"
rust_decimal_macros = "1.26.1"
rust_decimal = "1.33.1"
rust_decimal_macros = "1.33.1"
# HTTP Requests (for many of the UCM commarnds)
reqwest = { version = "0.11.12", features = ["json", "cookies"] }
reqwest = { version = "0.11.23", features = ["json", "cookies"] }
# Primitive derivation
num-traits = "0.2.15"
num-derive = "0.4.0"
num-traits = "0.2.17"
num-derive = "0.4.1"
# Music stuff
songbird = { version = "0.3.0", default-features = false, features = ["serenity-rustls", "gateway"] }
lavalink-rs = { git = "https://github.com/DoggySazHi/lavalink-rs-moogan", branch = "master", features = ["rustls", "serenity", "songbird"] }
songbird = { version = "0.4.0", default-features = false, features = ["serenity", "rustls", "gateway"] }
lavalink-rs = { git = "https://github.com/DoggySazHi/lavalink-rs-moogan", branch = "main", features = ["rustls", "serenity", "songbird"] }
# lavalink-rs = { path = "../lavalink-rs", features = ["rustls", "serenity", "songbird"] }
# Literally in the name
regex = "1.7.0"
regex = "1.10.2"
# Wait bruh enums can't be bits?
bitflags = "2.2.1"
bitflags = "2.4.2"
# Traits aren't async?
async-trait = "0.1.58"
async-trait = "0.1.77"
# Slash command framework
poise = { git = "https://github.com/DoggySazHi/poise-moogan", branch = "develop" }
poise = "0.6.1"
# poise = { path = "../poise" }
# System info lol
sysinfo = "0.29.8"
sysinfo = "0.30.5"
# Minecraft protocols
proto-mc = { git = "https://github.com/DoggySazHi/proto-mc" }
# RNG
rand = "0.8.5"
# Wtf serenity
secrecy = { version = "0.8.0", features = ["serde"] }

# Discord API
[dependencies.serenity]
Expand All @@ -66,11 +68,11 @@ features = [
"unstable_discord_api", # For slash commands/components
"voice"
]
version = "0.11.5"
version = "0.12.0"

# SQL Server
[dependencies.tiberius]
version = "0.12.1"
version = "0.12.2"
default-features = false
features = [
"tds73",
Expand Down
36 changes: 18 additions & 18 deletions src/commands/cowboard/cowboard_config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use poise::CreateReply;
use serenity::all::{CreateEmbed, CreateWebhook};
use tracing::error;
use crate::{CowContext, cowdb, Error};
use serenity::model::channel::ReactionType;
use serenity::model::id::ChannelId;
use serenity::utils::MessageBuilder;
use crate::{Database, db};
use secrecy::ExposeSecret;

#[poise::command(
prefix_command,
Expand All @@ -21,20 +24,17 @@ pub async fn info_code(ctx: CowContext<'_>) -> Result<(), Error> {

if let Some(guild_id) = ctx.guild_id() {
if let Ok(config) = db.get_cowboard_config(guild_id).await {
ctx.send(|m| {
m.embeds.clear();
m.embed(|e|
e
.title("Cowboard Settings")
.description("If the emote doesn't display properly below, you probably want to use a different one!")
.field("Emote", &config.emote, true)
.field("Raw Emote", MessageBuilder::new().push_mono(&config.emote).build(), true)
.field("Channel", config.channel.map(|o| format!("<#{o}>")).unwrap_or_else(|| "No Cowboard Channel".to_string()), true)
.field("Add Threshold", MessageBuilder::new().push_mono(config.add_threshold).build(), true)
.field("Remove Threshold", MessageBuilder::new().push_mono(config.remove_threshold).build(), true)
.field("Webhook", if config.webhook_id.is_some() && config.webhook_token.is_some() { "Enabled" } else { "Disabled" }, true)
)
}).await?;
let embed = CreateEmbed::new()
.title("Cowboard Settings")
.description("If the emote doesn't display properly below, you probably want to use a different one!")
.field("Emote", &config.emote, true)
.field("Raw Emote", MessageBuilder::new().push_mono(&config.emote).build(), true)
.field("Channel", config.channel.map(|o| format!("<#{o}>")).unwrap_or_else(|| "No Cowboard Channel".to_string()), true)
.field("Add Threshold", MessageBuilder::new().push_mono(format!("{}", config.add_threshold)).build(), true)
.field("Remove Threshold", MessageBuilder::new().push_mono(format!("{}", config.remove_threshold)).build(), true)
.field("Webhook", if config.webhook_id.is_some() && config.webhook_token.is_some() { "Enabled" } else { "Disabled" }, true);

ctx.send(CreateReply::default().embed(embed)).await?;
} else {
ctx.say("Failed to fetch Cowboard settings for this server...").await?;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ pub async fn channel(

match db.get_cowboard_config(guild_id).await {
Ok(mut config) => {
config.channel = Some(cowboard_channel.0);
config.channel = Some(cowboard_channel.get());
config.webhook_id = None;
config.webhook_token = None;

Expand Down Expand Up @@ -246,10 +246,10 @@ pub async fn webhook(ctx: CowContext<'_>) -> Result<(), Error> {
if let Some(guild_channel) = guild_channels.get(&channel)
{
if config.webhook_id.is_none() {
match guild_channel.create_webhook(&ctx, "MooganCowboard").await {
match guild_channel.create_webhook(&ctx, CreateWebhook::new("MooganCowboard")).await {
Ok(webhook) => {
config.webhook_id = Some(webhook.id.0);
config.webhook_token = Some(webhook.token.unwrap())
config.webhook_id = Some(webhook.id.get());
config.webhook_token = Some(webhook.token.unwrap().expose_secret().clone())
}
Err(ex) => {
ctx.say(format!("Failed to add webhook; maybe I do not have permissions for the channel <#{guild_channel}>?")).await?;
Expand Down
34 changes: 17 additions & 17 deletions src/commands/cowboard/cowboard_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ use crate::commands::cowboard::cowboard_db_models::*;
impl Database {
pub async fn get_cowboard_config(&self, server_id: GuildId) -> Result<Cowboard, Box<dyn std::error::Error + Send + Sync>> {
let mut conn = self.pool.get().await?;
let server = Decimal::from_u64(*server_id.as_u64()).unwrap();
let server = Decimal::from_u64(server_id.get()).unwrap();
let res = conn.query(
"SELECT channel, add_threshold, remove_threshold, emote, webhook_id, webhook_token FROM [Cowboard].[Server] WHERE id = @P1",
&[&server])
.await?
.into_row()
.await?;

let mut out = Cowboard::new(server_id.0);
let mut out = Cowboard::new(server_id.get());

if let Some(item) = res {
let channel_id: Option<Decimal> = item.get(0);
let emote_str: &str = item.get(3).unwrap();
let webhook_id: Option<Decimal> = item.get(4);
let webhook_token: Option<&str> = item.get(5);
out = Cowboard {
id: server_id.0,
id: server_id.get(),
channel: channel_id.and_then(|o| o.to_u64()),
add_threshold: item.get(1).unwrap(),
remove_threshold: item.get(2).unwrap(),
Expand Down Expand Up @@ -63,9 +63,9 @@ impl Database {

pub async fn get_cowboard_message(&self, message: MessageId, channel: ChannelId, guild: GuildId) -> Result<Option<CowboardMessage>, Box<dyn std::error::Error + Send + Sync>> {
let mut conn = self.pool.get().await?;
let message_decimal = Decimal::from_u64(message.0).unwrap();
let channel_decimal = Decimal::from_u64(channel.0).unwrap();
let server_decimal = Decimal::from_u64(guild.0).unwrap();
let message_decimal = Decimal::from_u64(message.get()).unwrap();
let channel_decimal = Decimal::from_u64(channel.get()).unwrap();
let server_decimal = Decimal::from_u64(guild.get()).unwrap();
let res = conn.query(
"SELECT post_id, post_channel_id FROM [Cowboard].[Message] WHERE message_id = @P1 AND message_channel_id = @P2 AND guild_id = @P3",
&[&message_decimal, &channel_decimal, &server_decimal])
Expand All @@ -80,11 +80,11 @@ impl Database {
let post_channel_id = item.get(1).and_then(|u: Decimal| u.to_u64()).unwrap();

out = Some(CowboardMessage {
message_id: message.0,
message_channel_id: channel.0,
message_id: message.get(),
message_channel_id: channel.get(),
post_id,
post_channel_id,
guild_id: guild.0
guild_id: guild.get()
});
}

Expand All @@ -93,11 +93,11 @@ impl Database {

pub async fn moo_message(&self, message: MessageId, channel: ChannelId, post_message: MessageId, post_channel: ChannelId, guild: GuildId) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut conn = self.pool.get().await?;
let message = Decimal::from_u64(message.0).unwrap();
let channel = Decimal::from_u64(channel.0).unwrap();
let post_message = Decimal::from_u64(post_message.0).unwrap();
let post_channel = Decimal::from_u64(post_channel.0).unwrap();
let server = Decimal::from_u64(guild.0).unwrap();
let message = Decimal::from_u64(message.get()).unwrap();
let channel = Decimal::from_u64(channel.get()).unwrap();
let post_message = Decimal::from_u64(post_message.get()).unwrap();
let post_channel = Decimal::from_u64(post_channel.get()).unwrap();
let server = Decimal::from_u64(guild.get()).unwrap();

conn.query(
"INSERT INTO [Cowboard].[Message] (message_id, message_channel_id, post_id, post_channel_id, guild_id) VALUES (@P1, @P2, @P3, @P4, @P5)",
Expand All @@ -109,9 +109,9 @@ impl Database {

pub async fn unmoo_message(&self, message: MessageId, channel: ChannelId, guild: GuildId) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let mut conn = self.pool.get().await?;
let message = Decimal::from_u64(message.0).unwrap();
let channel = Decimal::from_u64(channel.0).unwrap();
let server = Decimal::from_u64(guild.0).unwrap();
let message = Decimal::from_u64(message.get()).unwrap();
let channel = Decimal::from_u64(channel.get()).unwrap();
let server = Decimal::from_u64(guild.get()).unwrap();

conn.query(
"DELETE FROM [Cowboard].[Message] WHERE message_id = @P1 AND message_channel_id = @P2 AND guild_id = @P3",
Expand Down
Loading

0 comments on commit 7039a90

Please sign in to comment.