Skip to content

Commit 9c8c4fd

Browse files
committed
send join and leave messages
1 parent 7dcdb46 commit 9c8c4fd

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/main/java/us/ajg0702/bots/ajsupport/InviteListener.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
66
import net.dv8tion.jda.api.events.guild.invite.GuildInviteCreateEvent;
77
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
8+
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
89
import net.dv8tion.jda.api.hooks.ListenerAdapter;
910
import org.jetbrains.annotations.NotNull;
1011

@@ -34,15 +35,35 @@ public InviteListener(SupportBot bot) {
3435
}
3536
}
3637

38+
@Override
39+
public void onGuildMemberRemove(GuildMemberRemoveEvent e) {
40+
String mention = "<@"+e.getUser().getId()+">";
41+
bot.getLogger().debug(e.getUser().getAsTag()+" left!");
42+
TextChannel welcomeChannel = bot.getJDA().getTextChannelById(698756204801032202L);
43+
if(welcomeChannel == null) {
44+
bot.getLogger().error("Cannot find welcome channel for aj's plugins! Cannot send leave message");
45+
} else {
46+
welcomeChannel.sendMessage( mention + " left.").queue();
47+
}
48+
}
49+
3750
@Override
3851
public void onGuildMemberJoin(@NotNull GuildMemberJoinEvent e) {
52+
String mention = "<@"+e.getUser().getId()+">";
53+
bot.getLogger().debug(e.getUser().getAsTag()+" joined!");
54+
55+
TextChannel welcomeChannel = bot.getJDA().getTextChannelById(698756204801032202L);
56+
if(welcomeChannel == null) {
57+
bot.getLogger().error("Cannot find welcome channel for aj's plugins! Cannot send join message");
58+
} else {
59+
welcomeChannel.sendMessage("Hey " + mention + ", welcome to the discord server for aj's Plugins! If you are here for support, make sure to read <#1064604482752762076>!").queue();
60+
}
61+
3962
TextChannel channel = bot.getJDA().getTextChannelById(698756204801032202L);
4063
if(channel == null) {
4164
bot.getLogger().error("Cannot find logger-log channel for aj's plugins!");
4265
return;
4366
}
44-
String mention = "<@"+e.getUser().getId()+">";
45-
bot.getLogger().debug(e.getUser().getAsTag()+" joined!");
4667
try {
4768
Thread.sleep(100);
4869
Map<String, Integer> newUses = getInviteCounts(e.getGuild());

0 commit comments

Comments
 (0)