Create guild in DB on guild join
This commit is contained in:
1 parent
c44ddd42be
commit
f71cdb324b
2 files changed
+9
-8
No files matched your search
@@ -245,19 +245,14 @@ public class GuildManager {
|
|||||||
session.save(entity);
|
session.save(entity);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
|
||||||
handleJoinEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
session.close();
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleJoinEvent() {
|
|
||||||
guild.getTextChannels()
|
guild.getTextChannels()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(textChannel -> textChannel.getName().equals("debug") || textChannel.getName().equals("log"))
|
.filter(textChannel -> textChannel.getName().equals("debug") || textChannel.getName().equals("log"))
|
||||||
.forEach(textChannel -> textChannel.sendMessage("Error logging enabled on channel " + textChannel.getAsMention()).queue());
|
.forEach(textChannel -> textChannel.sendMessage("Error logging enabled on channel " + textChannel.getAsMention()).queue());
|
||||||
|
}
|
||||||
|
|
||||||
|
session.close();
|
||||||
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadEntity() {
|
public void reloadEntity() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package netneutrality.handler.hooks.guilds;
|
|||||||
* https://discord.gg/CdFcyQ
|
* https://discord.gg/CdFcyQ
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.GuildLeaveEvent;
|
import net.dv8tion.jda.api.events.guild.GuildLeaveEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import netneutrality.core.GuildManager;
|
import netneutrality.core.GuildManager;
|
||||||
@@ -14,6 +15,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class ServerJoinHandler extends ListenerAdapter {
|
public class ServerJoinHandler extends ListenerAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuildJoin(@NotNull GuildJoinEvent event) {
|
||||||
|
GuildManager.getManager(event.getGuild());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildLeave(@NotNull GuildLeaveEvent event) {
|
public void onGuildLeave(@NotNull GuildLeaveEvent event) {
|
||||||
GuildManager.getManager(event.getGuild()).removeFromDB();
|
GuildManager.getManager(event.getGuild()).removeFromDB();
|
||||||
|
|||||||
Reference in new issue
Block a user