Skip to content

Commit

Permalink
Attempt to load guild-specified declarations and override with a glob…
Browse files Browse the repository at this point in the history
…ally declared default if none exists

x2
  • Loading branch information
valzargaming committed Aug 23, 2021
1 parent 3c40c6f commit 605ed57
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 27 deletions.
4 changes: 2 additions & 2 deletions functions/guildbanadd-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ function guildBanAdd($ban, $discord) {
}

//Load config variables for the guild
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
if (!include "$guild_config_path") {
if($GLOBALS['debug_echo']) echo "CONFIG CATCH!" . PHP_EOL;
$counter = $GLOBALS[$guild_id."_config_counter"] ?? 0;
if ($counter <= 10) {
$GLOBALS[$guild_id."_config_counter"]++;
} else {
$discord->guilds->leave($guild);
rmdir(getcwd() . $guild_folder);
rmdir(getcwd() . $guild_folder);
if($GLOBALS['debug_echo']) echo "[GUILD DIR REMOVED - BAN]" . PHP_EOL;
}
}
Expand Down
4 changes: 2 additions & 2 deletions functions/guildbanremove-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ function guildBanRemove($ban, $discord) {
}

//Load config variables for the guild
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
if (!include "$guild_config_path") {
if($GLOBALS['debug_echo']) echo "CONFIG CATCH!" . PHP_EOL;
$counter = $GLOBALS[$guild_id."_config_counter"] ?? 0;
if ($counter <= 10) {
$GLOBALS[$guild_id."_config_counter"]++;
} else {
$discord->guilds->leave($guild);
rmdir(getcwd() . $guild_folder);
rmdir(getcwd() . $guild_folder);
if($GLOBALS['debug_echo']) echo "[GUILD DIR REMOVED - BAN]" . PHP_EOL;
}
}
Expand Down
2 changes: 1 addition & 1 deletion functions/guildmemberadd-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function guildMemberAdd($guildmember, $discord) {

//Load config variables for the guild
$guild_folder = "\\guilds\\$author_guild_id";
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
include "$guild_config_path";
if ($welcome_log_channel_id) {
$welcome_log_channel = $guildmember->guild->channels->get('id', $welcome_log_channel_id);
Expand Down
2 changes: 1 addition & 1 deletion functions/guildmemberremove-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function guildMemberRemove($guildmember, $discord) {
$author_guild_id = $guildmember->guild->id;
//Load config variables for the guild
$guild_folder = "\\guilds\\$author_guild_id";
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
include "$guild_config_path";

try {
Expand Down
4 changes: 2 additions & 2 deletions functions/guildmemberupdate-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ($error) {
}

//Load config variables for the guild
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
if (!include "$guild_config_path") {
if($GLOBALS['debug_echo']) echo "CONFIG CATCH!" . PHP_EOL;
$counter = $GLOBALS[$author_guild_id."_config_counter"] ?? 0;
Expand All @@ -99,7 +99,7 @@ function ($error) {
var_dump($error->getMessage());
}
);
rmdir(getcwd() . $guild_folder);
rmdir(getcwd() . $guild_folder);
if($GLOBALS['debug_echo']) echo "GUILD DIR REMOVED" . PHP_EOL;
}
}
Expand Down
38 changes: 25 additions & 13 deletions functions/message-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function message($message, $discord, $loop, $token, $restcord, $stats, $twitch,
else $booster = false;

//Load config variables for the guild
$guild_config_path = getcwd() . "\\$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "\\$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
if (!CheckFile($guild_folder, "guild_config.php")) {
$file = 'guild_config_template.php';
if (!copy(getcwd() . '/vendor/vzgcoders/palace/' . $file, $guild_config_path)) {
Expand Down Expand Up @@ -427,19 +427,31 @@ function ($watcher_dmchannel) use ($message) { //Promise
if ($admin) if($GLOBALS['debug_echo']) echo "[ADMIN $author_guild_id/$author_id] " . PHP_EOL;
if ($mod) if($GLOBALS['debug_echo']) echo "[MOD $author_guild_id/$author_id] " . PHP_EOL;
//if($GLOBALS['debug_echo']) echo PHP_EOL;

global $gameroles, $gameroles_message_text;
global $species, $species2, $species3, $species_message_text, $species2_message_text, $species3_message_text;
global $gender, $gender_message_text;
global $pronouns, $pronouns_message_text;
global $sexualities, $sexuality_message_text;
global $nsfwroles, $nsfw_message_text;
global $channelroles, $channelroles_message_text;
$guild_custom_roles_path = getcwd() . "$guild_folder\\custom_roles.php";
if (!include "$guild_custom_roles_path") //Overwrite default customroles

global $species, $species2, $species3, $species_message_text, $species2_message_text, $species3_message_text, $nsfwsubroles;
//Attempt to load guild-specified declarations and override with a globally declared default if none exists
$guild_game_roles_path = getcwd() . "$guild_folder\\game_roles.php";
if (!include "$guild_game_roles_path")
global $gameroles, $gameroles_message_text;
$guild_gender_roles_path = getcwd() . "$guild_folder\\gender.php";
if (!include "$guild_gender_roles_path")
global $gender, $gender_message_text;
$guild_pronouns_roles_path = getcwd() . "$guild_folder\\pronouns.php";
if (!include "$guild_pronouns_roles_path")
global $pronouns, $pronouns_message_text;
$guild_sexualities_roles_path = getcwd() . "$guild_folder\\sexualities.php";
if (!include "$guild_sexualities_roles_path")
global $sexualities, $sexuality_message_text;
$guild_nsfw_roles_path = getcwd() . "$guild_folder\\nsfw_roles.php";
if (!include "$guild_nsfw_roles_path")
global $nsfwroles, $nsfw_message_text;
$guild_channel_roles_path = getcwd() . "$guild_folder\\channel_roles.php";
if (!include "$guild_channel_roles_path")
global $channelroles, $channelroles_message_text;
$guild_custom_roles_path = getcwd() . "$guild_folder\\custom_roles.php";
if (!include "$guild_custom_roles_path")
global $customroles, $customroles_message_text;


/*
*********************
*********************
Expand Down Expand Up @@ -878,7 +890,7 @@ function ($watcher_dmchannel) use ($message) { //Promise
}
break;
case 'clearconfig': //;clearconfig
$files = glob(getcwd() . "$guild_folder" . '/*');
$files = glob(getcwd() . "$guild_folder" . '/*');
// Deleting all the files in the list
foreach ($files as $file) {
if (is_file($file)) {
Expand Down
2 changes: 1 addition & 1 deletion functions/messagedeleteraw-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function messageDeleteRaw($channel, $message_id, $discord) {
$guild = $channel->guild ?? $discord->guilds->offsetGet($author_guild_id);
//Load config variables for the guild
$guild_folder = "\\guilds\\$author_guild_id";
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
include "$guild_config_path"; //$modlog_channel_id
$modlog_channel = $guild->channels->get('id', $modlog_channel_id);
if($modlog_channel) $modlog_channel->sendEmbed($embed);
Expand Down
25 changes: 22 additions & 3 deletions functions/messagereactionadd-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,32 @@ function messageReactionAdd($reaction, $discord) {
$guild_folder = "\\guilds\\$author_guild_id";
CheckDir($guild_folder);
//Load config variables for the guild
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
include "$guild_config_path";

//Role picker stuff
$message_id = $message->id; //if($GLOBALS['debug_echo']) echo "message_id: " . $message_id . PHP_EOL;
global $gameroles, $species, $species2, $species3, $sexualities, $gender, $pronouns, $channelroles, $nsfwroles, $nsfwsubroles;
$guild_custom_roles_path = getcwd() . "$guild_folder\\custom_roles.php";
global $species, $species2, $species3, $nsfwsubroles;
//Attempt to load guild-specified declarations and override with a globally declared default if none exists
$guild_game_roles_path = getcwd() . "$guild_folder\\game_roles.php";
if (!include "$guild_game_roles_path")
global $gameroles, $gameroles_message_text;
$guild_gender_roles_path = getcwd() . "$guild_folder\\gender.php";
if (!include "$guild_gender_roles_path")
global $gender, $gender_message_text;
$guild_pronouns_roles_path = getcwd() . "$guild_folder\\pronouns.php";
if (!include "$guild_pronouns_roles_path")
global $pronouns, $pronouns_message_text;
$guild_sexualities_roles_path = getcwd() . "$guild_folder\\sexualities.php";
if (!include "$guild_sexualities_roles_path")
global $sexualities, $sexuality_message_text;
$guild_nsfw_roles_path = getcwd() . "$guild_folder\\nsfw_roles.php";
if (!include "$guild_nsfw_roles_path")
global $nsfwroles, $nsfw_message_text;
$guild_channel_roles_path = getcwd() . "$guild_folder\\channel_roles.php";
if (!include "$guild_channel_roles_path")
global $channelroles, $channelroles_message_text;
$guild_custom_roles_path = getcwd() . "$guild_folder\\custom_roles.php";
if (!include "$guild_custom_roles_path")
global $customroles;

Expand Down
2 changes: 1 addition & 1 deletion functions/messageupdate-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function messageUpdate($message_new, $discord, $message_old) {
}

//Load config variables for the guild
$guild_config_path = getcwd() . "\\$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "\\$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
if (!CheckFile($guild_folder, "guild_config.php")) {
$file = 'guild_config_template.php';
if (!copy(getcwd() . '/vendor/vzgcoders/palace/' . $file, $guild_config_path)) {
Expand Down
2 changes: 1 addition & 1 deletion functions/messageupdateraw-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function messageUpdateRaw($channel, $data_array, $discord) {
$author_guild_id = $guild->id;
//Load config variables for the guild
$guild_folder = "\\guilds\\$author_guild_id";
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
$guild_config_path = getcwd() . "$guild_folder\\guild_config.php"; //if($GLOBALS['debug_echo']) echo "guild_config_path: " . $guild_config_path . PHP_EOL;
include "$guild_config_path";

$modlog_channel = $guild->channels->get('id', $modlog_channel_id);
Expand Down

0 comments on commit 605ed57

Please sign in to comment.