This commit is contained in:
Chayapak 2023-06-11 20:57:08 +07:00
parent 6af27156df
commit 483e154b1b

View file

@ -106,15 +106,15 @@ public class DiscordPlugin {
jda.addEventListener(new ListenerAdapter() { jda.addEventListener(new ListenerAdapter() {
@Override @Override
public void onMessageReceived(@NotNull MessageReceivedEvent event) { public void onMessageReceived(@NotNull MessageReceivedEvent event) {
// TODO: IMPROVE this code because why make 172 lines just for a single discord message // TODO: IMPROVE this code because why make 174 lines just for a fucking single discord message
if ( if (
!event.getChannel().getId().equals(channelId) || !event.getChannel().getId().equals(channelId) ||
event.getAuthor().getId().equals(jda.getSelfUser().getId()) || event.getAuthor().getId().equals(jda.getSelfUser().getId()) ||
!bot.loggedIn() !bot.loggedIn()
) return; ) return;
final Message _message = event.getMessage(); final Message messageEvent = event.getMessage();
final String message = _message.getContentRaw(); final String message = messageEvent.getContentRaw();
if (message.startsWith(prefix)) { if (message.startsWith(prefix)) {
final DiscordCommandContext context = new DiscordCommandContext(bot, prefix, event, null, null); final DiscordCommandContext context = new DiscordCommandContext(bot, prefix, event, null, null);
@ -131,9 +131,9 @@ public class DiscordPlugin {
// ignore my very very ohio code,..,,. // ignore my very very ohio code,..,,.
Component attachmentsComponent = Component.empty(); Component attachmentsComponent = Component.empty();
if (_message.getAttachments().size() > 0) { if (messageEvent.getAttachments().size() > 0) {
attachmentsComponent = attachmentsComponent.append(Component.space()); attachmentsComponent = attachmentsComponent.append(Component.space());
for (Message.Attachment attachment : _message.getAttachments()) { for (Message.Attachment attachment : messageEvent.getAttachments()) {
attachmentsComponent = attachmentsComponent attachmentsComponent = attachmentsComponent
.append( .append(
Component Component
@ -146,9 +146,9 @@ public class DiscordPlugin {
} }
Component embedsComponent = Component.empty(); Component embedsComponent = Component.empty();
if (_message.getEmbeds().size() > 0) { if (messageEvent.getEmbeds().size() > 0) {
if (_message.getAttachments().size() == 0) embedsComponent = embedsComponent.append(Component.space()); if (messageEvent.getAttachments().size() == 0) embedsComponent = embedsComponent.append(Component.space());
for (MessageEmbed embed : _message.getEmbeds()) { for (MessageEmbed embed : messageEvent.getEmbeds()) {
final Component hoverEvent = Component.translatable( final Component hoverEvent = Component.translatable(
""" """
Title: %s Title: %s