Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev build #110

Merged
merged 50 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e1adca1
Merge pull request #36 from xp-bot/dev
crnvl Aug 21, 2023
900e09a
merge(#42): fix remaining bugs for iteration 1
crnvl Aug 25, 2023
215c338
Merge pull request #54 from xp-bot/preview
crnvl Sep 1, 2023
43cd805
Merge pull request #56 from xp-bot/preview
crnvl Sep 1, 2023
b762086
Merge pull request #58 from xp-bot/preview
crnvl Sep 1, 2023
6132b8b
Merge pull request #60 from xp-bot/preview
crnvl Sep 1, 2023
e50a43d
Merge pull request #62 from xp-bot/preview
crnvl Sep 1, 2023
2e86b07
feat: remove vmng
crnvl Sep 1, 2023
5069f70
Merge pull request #63 from xp-bot/dev
crnvl Sep 1, 2023
856f1d5
Update Cargo.toml
crnvl Sep 1, 2023
4f12c7d
Merge pull request #64 from xp-bot/dev
crnvl Sep 1, 2023
4456ec9
fix: docker cd
crnvl Sep 1, 2023
1fb1556
Merge pull request #65 from xp-bot/dev
crnvl Sep 1, 2023
652f460
Update Dockerfile
crnvl Sep 1, 2023
c927bf4
Merge pull request #66 from xp-bot/dev
crnvl Sep 1, 2023
5a6436d
Update Dockerfile
crnvl Sep 1, 2023
562e557
Merge branch 'master' of https://github.com/xp-bot/v8
crnvl Sep 1, 2023
37d4254
Update Dockerfile
crnvl Sep 1, 2023
22e3d89
Merge pull request #67 from xp-bot/dev
crnvl Sep 1, 2023
b13b046
merge: pull request #68 from xp-bot/master
crnvl Sep 1, 2023
2127290
fix: docker deployment
crnvl Sep 1, 2023
ae40949
feat: party command (#44)
crnvl Sep 3, 2023
c6f4d22
feat: show xp until in /level if not reached (#70)
crnvl Sep 3, 2023
0f1116f
Create assign.yml
crnvl Sep 4, 2023
14d7217
feat: game logic (#43)
crnvl Sep 4, 2023
dc052fd
fix: remove button for expired party lobbies
crnvl Sep 4, 2023
ad7afd5
feat: integrate new connector auth (#46)
crnvl Sep 4, 2023
e8a4530
feat: show last daily streak if broken (#31)
crnvl Sep 4, 2023
153b44b
feat: gateway latency in about (#30)
crnvl Sep 4, 2023
6414ff5
feat: update dockerfile structure
crnvl Sep 6, 2023
aa7c6a6
fix: daily limit does not work (#77)
crnvl Sep 8, 2023
145870f
feat: handle level roles (#79)
crnvl Sep 11, 2023
a41c5f6
chore: remove auto assign workflow
crnvl Sep 11, 2023
800ed7c
feat: comply with xpcs set xp specs (#82)
crnvl Sep 11, 2023
8a60000
feat: XP welcome message (#9)
crnvl Sep 11, 2023
882eeb7
fix: import warnings in handler.rs
crnvl Sep 11, 2023
93db962
feat: implement role check for admin commands
crnvl Sep 11, 2023
12d8c9c
fix: user identification for role rewards
crnvl Sep 11, 2023
f7b9d2c
fix(vtm): invalidate timestamps after session ends (#75)
crnvl Sep 12, 2023
76f1d28
fix(vtm): ignored voicechats no longer add to user xp (#88)
crnvl Sep 12, 2023
981ad56
fix: false displayment of daily reward (#98)
crnvl Sep 12, 2023
8be7b5d
feat: autorole support (#90)
crnvl Sep 12, 2023
204c0ee
fix: vote-free servers not working (#102)
crnvl Sep 15, 2023
496c078
fix(vtm): channel leave event does not assign xp
crnvl Sep 15, 2023
e66c346
chore: remove logs
crnvl Sep 15, 2023
cc412b2
fix: xp assignment issues (#106)
crnvl Sep 20, 2023
9cc76d0
feat: do not send ranking card if user is incognito (#105)
crnvl Sep 20, 2023
a026dde
fix: vote-free servers still require votes
crnvl Sep 20, 2023
a795d9f
feat: remove autonick addition if user is incognito (#108)
crnvl Sep 21, 2023
110fa2c
temp: testing build
crnvl Sep 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM rust:latest
WORKDIR /usr/src
COPY . .

RUN cargo install --path xp-bot
RUN cargo build --release
EXPOSE 80

CMD ["cargo", "run", "--release"]
CMD ["./target/release/xp-bot"]
12 changes: 0 additions & 12 deletions vmng/Cargo.toml

This file was deleted.

74 changes: 0 additions & 74 deletions vmng/src/main.rs

This file was deleted.

10 changes: 8 additions & 2 deletions xp-bot/src/commands/admin/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use serenity::{
},
prelude::Context,
};
use xp_db_connector::guild_member::GuildMember;
use xp_db_connector::{guild_member::GuildMember, guild::Guild};

use crate::{commands::XpCommand, utils::{colors, utils::format_number}};
use crate::{commands::XpCommand, utils::{colors, utils::{format_number, handle_level_roles}, math::calculate_level}};

pub struct AddCommand;

Expand Down Expand Up @@ -80,6 +80,9 @@ impl XpCommand for AddCommand {

let new_amount = guild_member.xp + amount;

let guild = Guild::from_id(guild_id).await?;
let new_level = calculate_level(&new_amount);

let _ = GuildMember::set_xp(guild_id, user, &new_amount, &guild_member).await?;

command
Expand All @@ -100,6 +103,9 @@ impl XpCommand for AddCommand {
})
.await?;

handle_level_roles(&guild, &user, &new_level, &ctx, command.guild_id.clone().unwrap().0).await;


Ok(())
}
}
9 changes: 7 additions & 2 deletions xp-bot/src/commands/admin/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use serenity::{
},
prelude::Context,
};
use xp_db_connector::guild_member::GuildMember;
use xp_db_connector::{guild_member::GuildMember, guild::Guild};

use crate::{commands::XpCommand, utils::{colors, utils::format_number}};
use crate::{commands::XpCommand, utils::{colors, utils::{format_number, handle_level_roles}, math::calculate_level}};

pub struct RemoveCommand;

Expand Down Expand Up @@ -79,6 +79,9 @@ impl XpCommand for RemoveCommand {

let new_amount = guild_member.xp - amount;

let guild = Guild::from_id(guild_id).await?;
let new_level = calculate_level(&new_amount);

let _ = GuildMember::set_xp(guild_id, user, &new_amount, &guild_member).await?;

command
Expand All @@ -99,6 +102,8 @@ impl XpCommand for RemoveCommand {
})
.await?;

handle_level_roles(&guild, &user, &new_level, &ctx, command.guild_id.clone().unwrap().0).await;

Ok(())
}
}
9 changes: 7 additions & 2 deletions xp-bot/src/commands/admin/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use serenity::{
},
prelude::Context,
};
use xp_db_connector::guild_member::GuildMember;
use xp_db_connector::{guild_member::GuildMember, guild::Guild};

use crate::{commands::XpCommand, utils::{colors, utils::format_number}};
use crate::{commands::XpCommand, utils::{colors, utils::{format_number, handle_level_roles}, math::calculate_level}};

pub struct SetCommand;

Expand Down Expand Up @@ -78,6 +78,9 @@ impl XpCommand for SetCommand {

let guild_member = GuildMember::from_id(guild_id, user).await?;

let guild = Guild::from_id(guild_id).await?;
let new_level = calculate_level(&amount);

let _ = GuildMember::set_xp(guild_id, user, &amount, &guild_member).await?;

command
Expand All @@ -98,6 +101,8 @@ impl XpCommand for SetCommand {
})
.await?;

handle_level_roles(&guild, &user, &new_level, &ctx, command.guild_id.clone().unwrap().0).await;

Ok(())
}
}
10 changes: 8 additions & 2 deletions xp-bot/src/commands/admin/setlevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use serenity::{
},
prelude::Context,
};
use xp_db_connector::guild_member::GuildMember;
use xp_db_connector::{guild_member::GuildMember, guild::Guild};

use crate::{
commands::XpCommand,
utils::{colors, math::get_required_xp},
utils::{colors, math::{get_required_xp, calculate_level}, utils::handle_level_roles},
};

pub struct SetLevelCommand;
Expand Down Expand Up @@ -82,6 +82,10 @@ impl XpCommand for SetLevelCommand {
let required_xp = get_required_xp(level as i32);

let guild_member = GuildMember::from_id(command.guild_id.unwrap().into(), user_id).await?;

let guild = Guild::from_id(command.guild_id.unwrap().into()).await?;
let new_level = calculate_level(&(required_xp as u64));

let _ = GuildMember::set_xp(
command.guild_id.unwrap().into(),
user_id,
Expand Down Expand Up @@ -109,6 +113,8 @@ impl XpCommand for SetLevelCommand {
})
.await;

handle_level_roles(&guild, &user_id, &new_level, &ctx, command.guild_id.clone().unwrap().0).await;

Ok(())
}
}
45 changes: 32 additions & 13 deletions xp-bot/src/commands/games/daily.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl XpCommand for DailyCommand {
return Ok(());
}

if !eligibility_helper(command.user.id.0).await {
if !eligibility_helper(command.user.id.0, &command.guild_id.unwrap().0).await {
command
.create_interaction_response(ctx, |response| {
response
Expand Down Expand Up @@ -121,19 +121,37 @@ impl XpCommand for DailyCommand {

let daily_xp = 250;

let mut old_streak_msg = String::new();
// reset streak if last daily was claimed more than 48 hours ago
let streak =
if time_now - guild_member.timestamps.game_daily.unwrap_or(0) as i64 > 86400 * 1000 * 2 {
1
} else {
guild_member.streaks.game_daily.unwrap_or(0) + 1
};

guild_member.xp += daily_xp * streak;
let streak = if time_now - guild_member.timestamps.game_daily.unwrap_or(0) as i64
> 86400 * 1000 * 2
{
old_streak_msg = format!(
"Your old streak was **{}**.",
guild_member.streaks.game_daily.unwrap_or(0)
);
1
} else {
guild_member.streaks.game_daily.unwrap_or(0) + 1
};

let member_xp = daily_xp * streak;
let xp_to_add = if member_xp > guild.values.maximumdailyxp as u64 {
guild.values.maximumdailyxp as u64
} else {
member_xp
};
guild_member.xp += xp_to_add;

guild_member.timestamps.game_daily = Some(time_now as u64);
guild_member.streaks.game_daily = Some(streak);

let _ = GuildMember::set_guild_member(command.guild_id.unwrap().0, command.user.id.0, guild_member).await?;
let _ = GuildMember::set_guild_member(
command.guild_id.unwrap().0,
command.user.id.0,
guild_member,
)
.await?;

command
.create_interaction_response(ctx, |response| {
Expand All @@ -142,9 +160,10 @@ impl XpCommand for DailyCommand {
.interaction_response_data(|message| {
message.embed(|embed| {
embed.description(format!(
"You claimed **{}** xp. Your streak is now **{}**.",
format_number(daily_xp * streak),
streak
"You claimed **{}** xp. Your streak is now **{}**.\n\n{}",
format_number(xp_to_add),
streak,
old_streak_msg
));
embed.color(colors::green())
})
Expand Down
13 changes: 8 additions & 5 deletions xp-bot/src/commands/games/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
commands::XpCommand,
utils::{
colors,
utils::{eligibility_helper, is_cooldowned, format_number},
utils::{eligibility_helper, is_cooldowned, format_number, game_fish},
},
};

Expand Down Expand Up @@ -58,7 +58,7 @@ impl XpCommand for FishCommand {
return Ok(());
}

if !eligibility_helper(command.user.id.0).await {
if !eligibility_helper(command.user.id.0, &command.guild_id.unwrap().0).await {
command
.create_interaction_response(ctx, |response| {
response
Expand Down Expand Up @@ -115,8 +115,10 @@ impl XpCommand for FishCommand {
return Ok(());
}

let game_result = game_fish(guild.values.fishXP as i64);

// assign xp
guild_member.xp += guild.values.fishXP as u64;
guild_member.xp += game_result.xp as u64;

// set new cooldown
guild_member.timestamps.game_fish = Some(time_now as u64);
Expand All @@ -134,8 +136,9 @@ impl XpCommand for FishCommand {
.interaction_response_data(|message| {
message.embed(|embed| {
embed.description(format!(
":fishing_pole_and_fish: | You caught a fish and gained **{}** xp!",
format_number(guild.values.fishXP as u64)
":fishing_pole_and_fish: | You got **{}** xp for finding **{}**.",
format_number(game_result.xp as u64),
game_result.item
));
embed.color(colors::green())
})
Expand Down
13 changes: 8 additions & 5 deletions xp-bot/src/commands/games/loot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
commands::XpCommand,
utils::{
colors,
utils::{eligibility_helper, format_number, is_cooldowned},
utils::{eligibility_helper, format_number, game_loot, is_cooldowned},
},
};

Expand Down Expand Up @@ -58,7 +58,7 @@ impl XpCommand for LootCommand {
return Ok(());
}

if !eligibility_helper(command.user.id.0).await {
if !eligibility_helper(command.user.id.0, &command.guild_id.unwrap().0).await {
command
.create_interaction_response(ctx, |response| {
response
Expand Down Expand Up @@ -117,8 +117,10 @@ impl XpCommand for LootCommand {
return Ok(());
}

let game_result = game_loot(guild.values.lootXP as i64);

// assign xp
guild_member.xp += guild.values.lootXP as u64;
guild_member.xp += game_result.xp as u64;

// set new cooldown
guild_member.timestamps.game_loot = Some(time_now as u64);
Expand All @@ -136,8 +138,9 @@ impl XpCommand for LootCommand {
.interaction_response_data(|message| {
message.embed(|embed| {
embed.description(format!(
":package: | You looted a crate and got **{}** xp!",
format_number(guild.values.lootXP as u64),
":package: | You found **{}** crate and got **{}** xp!",
game_result.item,
format_number(game_result.xp as u64),
));
embed.color(colors::green())
})
Expand Down
3 changes: 2 additions & 1 deletion xp-bot/src/commands/games/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pub mod fish;
pub mod roll;
pub mod loot;
pub mod daily;
pub mod trivia;
pub mod trivia;
pub mod party;
Loading
Loading