Skip to content

Commit

Permalink
Fix breakage from serenity data
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Jan 19, 2024
1 parent ae18808 commit 7125e39
Show file tree
Hide file tree
Showing 17 changed files with 169 additions and 200 deletions.
73 changes: 33 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ features = ["cache"]
branch = "serenity-next"

[dependencies.songbird]
git = "https://github.com/serenity-rs/songbird"
git = "https://github.com/GnomedDev/songbird"
features = ["builtin-queue"]
branch = "serenity-next"
branch = "fix-id"
version = "0.4"
8 changes: 4 additions & 4 deletions src/commands/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ pub async fn join(ctx: Context<'_>) -> CommandResult {
if let Some(bot_vc) = data.songbird.get(guild_id) {
let bot_channel_id = bot_vc.lock().await.current_channel();
if let Some(bot_channel_id) = bot_channel_id {
if bot_channel_id.0.get() == author_vc.get() {
if bot_channel_id.get() == author_vc.get() {
ctx.say(ctx.gettext("I am already in your voice channel!"))
.await?;
return Ok(());
};

ctx.say(
ctx.gettext("I am already in <#{channel_id}>!")
.replace("{channel_id}", &bot_channel_id.0.to_string()),
.replace("{channel_id}", &bot_channel_id.to_string()),
)
.await?;
return Ok(());
Expand All @@ -126,7 +126,7 @@ pub async fn join(ctx: Context<'_>) -> CommandResult {
{
let _typing = ctx.defer_or_broadcast().await?;

let join_vc_lock = JoinVCToken::acquire(data, guild_id);
let join_vc_lock = JoinVCToken::acquire(&data, guild_id);
let join_vc_result = data
.songbird
.join_vc(join_vc_lock.lock().await, author_vc)
Expand Down Expand Up @@ -191,7 +191,7 @@ pub async fn leave(ctx: Context<'_>) -> CommandResult {

if let Some(bot_vc) = bot_vc {
if !channel_check(&ctx, author_vc).await? {
} else if author_vc.map_or(true, |author_vc| bot_vc.0.get() != author_vc.get()) {
} else if author_vc.map_or(true, |author_vc| bot_vc.get() != author_vc.get()) {
ctx.say(ctx.gettext(
"Error: You need to be in the same voice channel as me to make me leave!",
))
Expand Down
2 changes: 1 addition & 1 deletion src/commands/premium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub async fn premium_deactivate(ctx: Context<'_>) -> CommandResult {
return Ok(());
}

remove_premium(data, guild_id).await?;
remove_premium(&data, guild_id).await?;

let msg = ctx.gettext("Deactivated premium from this server.");
ctx.say(msg).await?;
Expand Down
15 changes: 7 additions & 8 deletions src/commands/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub async fn settings(ctx: Context<'_>) -> CommandResult {
if guild_voice_row.guild_id.is_none() {
Cow::Borrowed(guild_mode.default_voice())
} else {
format_voice(data, &guild_voice_row.voice, guild_mode)
format_voice(&data, &guild_voice_row.voice, guild_mode)
}
};

Expand All @@ -120,7 +120,7 @@ pub async fn settings(ctx: Context<'_>) -> CommandResult {
.voice
.as_ref()
.map_or(Cow::Borrowed(none_str), |voice| {
format_voice(data, voice, currently_set_voice_mode)
format_voice(&data, voice, currently_set_voice_mode)
})
};

Expand Down Expand Up @@ -353,15 +353,14 @@ async fn voice_autocomplete<'a>(
ctx: ApplicationContext<'a>,
searching: &'a str,
) -> Vec<serenity::AutocompleteChoice<'a>> {
let Ok((_, mode)) = ctx
.data
let data = ctx.data();
let Ok((_, mode)) = data
.parse_user_or_guild(ctx.interaction.user.id, ctx.interaction.guild_id)
.await
else {
return Vec::new();
};

let data = ctx.data;
let (mut i1, mut i2, mut i3, mut i4);
let voices: &mut dyn Iterator<Item = _> = match mode {
TTSMode::gTTS => {
Expand Down Expand Up @@ -420,7 +419,7 @@ async fn translation_languages_autocomplete<'a>(
searching: &'a str,
) -> impl Iterator<Item = serenity::AutocompleteChoice<'a>> {
let mut filtered_languages = ctx
.data
.data()
.translation_languages
.iter()
.filter(|(_, name)| name.starts_with(searching))
Expand Down Expand Up @@ -529,11 +528,11 @@ where
let data = ctx.data();
let (_, mode) = data.parse_user_or_guild(author_id, Some(guild_id)).await?;
Ok(if let Some(voice) = voice {
if check_valid_voice(data, &voice, mode) {
if check_valid_voice(&data, &voice, mode) {
general_db.create_row(key).await?;
voice_db.set_one((key, mode), "voice", &voice).await?;

let name = get_voice_name(data, &voice, mode).unwrap_or(&voice);
let name = get_voice_name(&data, &voice, mode).unwrap_or(&voice);
Cow::Owned(
match target {
Target::Guild => ctx.gettext("Changed the server voice to: {voice}"),
Expand Down
Loading

0 comments on commit 7125e39

Please sign in to comment.