Kinda new to GitHub, so I don't quite get how to implement my own code solutions into the code without officially submitting it. This piece of code would be for automatically removing the Whitelist of someone when they lose a specific role. My use of this is for a Twitch sub only minecraft server that would remove the whitelist once they are no longer a Twitch Subscriber (Role in Discord), but I have not a single clue of how to make the .jar file myself, and all of my attempts have not worked. I adapted the onGuildMemberRemove function to create this. As far as I can tell the function should work, all that would need to be implemented is a way in the config file to enable or disable it, and to add a role to check for. This code uses the GuildMemberRoleRemove event to work. Below is the code:
@Override
public void onGuildMemberRoleRemove(@Nonnull GuildMemberRoleRemoveEvent event)
{
for(Role rl : event.getMember().getRoles())
{
if(rl.getName() == "Twitch Subscriber")
{
return;
}
}
String discordUserToRemove = event.getMember().getId();
DiscordWhitelister.getPlugin().getLogger().info(discordUserToRemove + " lost their sub. Removing their whitelisted entries...");
List<?> ls = UserList.getRegisteredUsers(discordUserToRemove);
if(ls != null)
{
for (Object minecraftNameToRemove : ls)
{
DiscordWhitelister.getPlugin().getLogger().info(minecraftNameToRemove.toString() + " lost their sub. Removing their whitelisted entries.");
if (WhitelistedPlayers.usingEasyWhitelist)
{
ExecuteServerCommand("easywl remove " + minecraftNameToRemove.toString());
} else
{
ExecuteServerCommand("whitelist remove " + minecraftNameToRemove.toString());
}
}
try
{
UserList.resetRegisteredUsers(discordUserToRemove);
}
catch (IOException e)
{
e.printStackTrace();
return;
}
DiscordWhitelister.getPlugin().getLogger().info(discordUserToRemove + " lost their sub. Successfully removed their whitelisted entries from the user list.");
}
else
{
DiscordWhitelister.getPlugin().getLogger().warning(discordUserToRemove + " lost their sub. Could not remove any whitelisted entries as they did not whitelist through this plugin.");
}
}
Kinda new to GitHub, so I don't quite get how to implement my own code solutions into the code without officially submitting it. This piece of code would be for automatically removing the Whitelist of someone when they lose a specific role. My use of this is for a Twitch sub only minecraft server that would remove the whitelist once they are no longer a Twitch Subscriber (Role in Discord), but I have not a single clue of how to make the .jar file myself, and all of my attempts have not worked. I adapted the onGuildMemberRemove function to create this. As far as I can tell the function should work, all that would need to be implemented is a way in the config file to enable or disable it, and to add a role to check for. This code uses the GuildMemberRoleRemove event to work. Below is the code: