#pragma once
bool areWeInADM(
input_event_data eventData, channel channel,
bool displayResponse =
true) {
auto currentChannelType = channel.type;
if (currentChannelType == channel_type::dm) {
if (displayResponse) {
jsonifier::string msgString = "------\n**sorry, but we can't do that in a direct message!**\n------";
msgEmbed->setAuthor(eventData.getMessageData().interaction.user.userName, eventData.getMessageData().author.avatar);
msgEmbed->setColor("fefefe");
msgEmbed->setDescription(msgString);
msgEmbed->setTitle("__**direct message issue:**__");
responseData->addMessageEmbed(*msgEmbed);
}
return true;
}
return false;
}
bool checkIfAllowedPlayingInChannel(
input_event_data eventData, discord_guild discordGuild) {
bool isItFound = true;
if (discordGuild.data.musicChannelIds.size() > 0) {
isItFound = false;
jsonifier::string msgString = "------\n**sorry, but please do that in one of the following channels:**\n------\n";
for (auto& value: discordGuild.data.musicChannelIds) {
if (eventData.getChannelId() == value) {
isItFound = true;
break;
} else {
msgString += "<#" + value + ">\n";
}
}
msgString += "------";
if (isItFound == false) {
msgEmbed->setAuthor(eventData.getUserName(), eventData.getAvatarUrl());
msgEmbed->setColor(discordGuild.data.borderColor);
msgEmbed->setDescription(msgString);
msgEmbed->setTitle("__**permissions issue:**__");
replyMessageData->addMessageEmbed(*msgEmbed);
;
}
}
return isItFound;
}
if (guildData.data.djRoleId == 0) {
return true;
}
bool doWeHaveControl = false;
discord_guild_member guildMemberData(guildMember);
for (const auto& value: myRoles) {
if (value.id == guildData.data.djRoleId) {
doWeHaveControl = true;
}
}
if (!doWeHaveControl) {
jsonifier::string msgString = "------\n**sorry, but you lack the permissions to do that!**\n------";
msgEmbed->setAuthor(guildMember.user.userName, guildMember.user.avatar);
msgEmbed->setDescription(msgString);
msgEmbed->setColor(guildData.data.borderColor);
msgEmbed->setTitle("permissions issue");
dataPackage->addMessageEmbed(*msgEmbed);
}
return doWeHaveControl;
}
bool checkForBotCommanderStatus(
guild_member_data guildMember, discord_user discordUser) {
bool areWeACommander;
for (auto& value: discordUser.data.botCommanders) {
if (guildMember.user.id == value) {
areWeACommander = true;
return areWeACommander;
break;
}
}
return false;
}
bool displayResponse = true) {
bool doWeHaveAdmin = guildMember.permissions.checkForPermission(guildMember, channel, permission_types::administrator);
if (doWeHaveAdmin) {
return true;
}
bool areWeACommander =
checkForBotCommanderStatus(guildMember, discord_user(discord_core_client::getInstance()->getBotUser().userName, discord_core_client::getInstance()->getBotUser().id));
if (areWeACommander) {
return true;
}
if (displayResponse) {
jsonifier::string msgString = "------\n**sorry, but you don't have the permissions required for that!**\n------";
msgEmbed->setAuthor(guildMember.user.userName, guildMember.user.avatar);
msgEmbed->setColor(discordGuild.data.borderColor);
msgEmbed->setDescription(msgString);
msgEmbed->setTitle("__**permissions issue:**__");
dataPackage->addMessageEmbed(*msgEmbed);
}
return false;
}
double applyAsymptoticTransform(double inputModValue, double horizontalStretch, double ceiling) {
double finalModValue = 0;
double newInputModValue = inputModValue;
if (newInputModValue == 0) {
newInputModValue++;
}
if (newInputModValue <= 0) {
double newInputValue = newInputModValue * -1;
finalModValue =
-1 * (double)trunc((ceiling * pow(newInputValue, 3))/((pow(newInputValue, 3) + (int64_t)horizontalStretch * (int64_t)newInputValue)));
return finalModValue;
}
finalModValue =
(double)trunc((ceiling * pow(newInputModValue, 3))/((pow(newInputModValue, 3) + (int64_t)horizontalStretch * (int64_t)newInputModValue)));
return finalModValue;
}
}
Data structure representing a single guild_member_data.
static co_routine< jsonifier::vector< role_data > > getGuildMemberRolesAsync(get_guild_member_roles_data dataPackage)
Collects the roles that a guild_member has.
A smart pointer class that provides unique ownership semantics.
DiscordCoreAPI_Dll jsonifier::string getTimeAndDate()
Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
@ Ephemeral_Interaction_Response
Ephemeral interaction response.
DCA_INLINE unique_ptr< value_type, deleter > makeUnique(arg_types &&... args)
Helper function to create a unique_ptr for a non-array object.
The main namespace for the forward-facing interfaces.
Base arguments for the command classes.