Skip to content

Commit

Permalink
[0.1.2.378]: Fix button error
Browse files Browse the repository at this point in the history
- Done fixing!
- Cancel is okay but cannot kick 😢

Co-Authored-By: Harshfeudal <[email protected]>
  • Loading branch information
harshfeudal and dhtson committed Oct 24, 2022
1 parent 7497e0e commit 73bdf6d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ These are libraries that we're using in this project:
- [Spdlog](https://github.com/gabime/spdlog) - version `1.10.0` (latest)

Bot current version:
- BETA version - `0.1.2.356` (`Release`)
- BETA version - `0.1.2.378` (`Release`)
- Stable version - `Unknown`

### 🚨 Generate and use
Expand Down
8 changes: 4 additions & 4 deletions Raiden Shogun.rc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <Winver.h>

#define FILEVERSION_STR "0.1.2.356"
#define PRODUCTVERSION_STR "0.1.2.356"
#define FILEVERSION_STR "0.1.2.378"
#define PRODUCTVERSION_STR "0.1.2.378"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,2,356
PRODUCTVERSION 0,1,2,356
FILEVERSION 0,1,2,378
PRODUCTVERSION 0,1,2,378
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
Expand Down
3 changes: 1 addition & 2 deletions handler/btnHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ inline void ButtonBind(dpp::component& component, const std::function<bool(const
customIdAlreadyExists = cachedSessions.find(customIdCounter) != cachedSessions.end();
if (!customIdAlreadyExists)
{
component.custom_id = std::to_string(customIdCounter);

Session session;
session.function = function;
session.cache_duration = cache_duration;
component.custom_id = std::to_string(customIdCounter);

component.custom_id += ID_SPACING + std::to_string(static_cast<long int>(session.created_at));

Expand Down
50 changes: 30 additions & 20 deletions src/kick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

void kick(dpp::cluster& client, const dpp::slashcommand_t& event)
{
auto tgtReason = event.get_parameter("reason");
const auto gFind = dpp::find_guild(event.command.guild_id);
auto usr = std::get<dpp::snowflake>(event.get_parameter("member"));

auto usr = std::get<dpp::snowflake>(event.get_parameter("member"));
auto tgtReason = event.get_parameter("reason");
auto source = event.command.usr.id;
auto gFind = dpp::find_guild(event.command.guild_id);
auto tgtGuild = event.command.guild_id;
const auto tgtUser = gFind->members.find(usr);

if (tgtUser == gFind->members.end())
Expand Down Expand Up @@ -51,20 +52,7 @@ void kick(dpp::cluster& client, const dpp::slashcommand_t& event)
.set_style(dpp::cos_secondary)
.set_id("cnl_Id");

dpp::message k_Confirm(
fmt::format("Do you want to kick <@{}>? Press the button below to confirm", usr)
);

k_Confirm.add_component(
dpp::component().add_component(k_Component)
.add_component(cnl_Component)
);

event.reply(
k_Confirm.set_flags(dpp::m_ephemeral)
);

ButtonBind(k_Component, [&client, tgtReason, usr, source = event.command.usr.id](const dpp::button_click_t& event)
ButtonBind(k_Component, [&client, tgtGuild, tgtReason, usr, source](const dpp::button_click_t& event)
{
if (source != event.command.usr.id)
{
Expand All @@ -74,16 +62,24 @@ void kick(dpp::cluster& client, const dpp::slashcommand_t& event)
std::string kContent = fmt::format("<@{}> has been kicked!", usr);

if (!std::holds_alternative<std::string>(tgtReason))
{
std::string k_Reason = "No kick reason provided";
}

std::string k_Reason = std::get<std::string>(tgtReason);
client.set_audit_reason(k_Reason);
client.guild_member_kick(event.command.guild_id, usr);
client.guild_member_kick_sync(tgtGuild, usr);

event.reply(
dpp::interaction_response_type::ir_update_message,
dpp::message().set_flags(dpp::m_ephemeral)
.set_content(kContent)
);

return true;
});

ButtonBind(cnl_Component, [source = event.command.usr.id](const dpp::button_click_t& event)
ButtonBind(cnl_Component, [source](const dpp::button_click_t& event)
{
std::string cnlContent = "Cancelled request!";

Expand All @@ -100,4 +96,18 @@ void kick(dpp::cluster& client, const dpp::slashcommand_t& event)

return true;
});

dpp::message k_Confirm(
fmt::format("Do you want to kick <@{}>? Press the button below to confirm", usr)
);

k_Confirm.add_component(
dpp::component().add_component(k_Component)
.add_component(cnl_Component)
);

event.reply(
k_Confirm.set_flags(dpp::m_ephemeral)
.set_channel_id(event.command.channel_id)
);
}

0 comments on commit 73bdf6d

Please sign in to comment.