DiscordSRV

DiscordSRV

86.8k Downloads

Support for AFK messages (essentials)

Opened this issue ยท 20 comments

commented

Add support for AFK messages to DiscordSRV. What I mean is, say someone ingame does /afk, a message should show not just ingame, but also in the discord:
"%player% is now AFK." "%player% is no longer AFK." Or:
"* %player% is now AFK." "* %player% is no longer AFK." like ingame - see below.
Ingame it looks like this (with the *); maybe even have it the same in Discord?
image
(this is through essentials, alas the word essentials in the title... I think this is the most popular, and best, plugin with /afk; as well as many other useful functions)
It would be a useful function since join/leave/kill and server start/stop messages are already there.
Please add it, I'm sure many people want this: tho I couldn't find any issue posts about it yet. :)

commented

Closing since this is possible with the alerts feature and so there is no need to add anything else

commented

Hi, is this still being planned for a future addition?

commented

yes

commented

yes

That's good to know, thanks, was worried that plans for it had been dropped silently. Will still be looking forward to an (possible) inclusion of this feature or something similar in future versions.

Thanks for all your hard work!

commented

@zerrium this is the worst way you could've asked for help. Please join our Discord at https://discordsrv.com/discord and go to the #support channel for help with configuring DiscordSRV.

commented

Hi, I have tried to config alerts.yml to forward afk message to Discord using Essentials' AFK event but it doesnt work:

[09:47:11 ERROR]: [DiscordSRV] Error while evaluating expression "#event.getValue() == true && #event.getAffected().getAfkMessage().isEmpty() == true" for trigger "afkstatuschangeevent" -> EL1011E: Method call: Attempted to call method isEmpty() on null context object [09:47:11 ERROR]: [DiscordSRV] Error while evaluating expression "#event.getValue() == true && #event.getAffected().getAfkMessage().isEmpty() == false" for trigger "afkstatuschangeevent" -> EL1011E: Method call: Attempted to call method isEmpty() on null context object

And here is my alerts.yml
The output
Did I do something wrong?

If I can't use that way, can you at least give me some hint how to forward a message from a plugin which listens to AFK event to DiscordSRV and post it to Discord?

commented

I have just finished making an addon to support that. I just waiting for someone to test. I will send the link when ready.

Add support for AFK messages to DiscordSRV. What I mean is, say someone ingame does /afk, a message should show not just ingame, but also in the discord:
"%player% is now AFK." "%player% is no longer AFK." Or:
"* %player% is now AFK." "* %player% is no longer AFK." like ingame - see below.
Ingame it looks like this (with the *); maybe even have it the same in Discord?
image
(this is through essentials, alas the word essentials in the title... I think this is the most popular, and best, plugin with /afk; as well as many other useful functions)
It would be a useful function since join/leave/kill and server start/stop messages are already there.
Please add it, I'm sure many people want this: tho I couldn't find any issue posts about it yet. :)

commented

Why would you need an addon when you can just use an existing feature of the plugin to do it? Seems like personal promotion to me

commented

Why would you need an addon when you can just use an existing feature of the plugin to do it? Seems like personal promotion to me

There is a feature of this in discordsrv? Sorry i didnt know

commented

Would just like to note that there is already a example for this kind of alert on the wiki, see https://github.com/DiscordSRV/DiscordSRV/wiki/alerts#afkstatuschangeevent

Though this is going to be added into DiscordSRV itself as well eventually.

commented

Would just like to note that there is already a example for this kind of alert on the wiki, see https://github.com/DiscordSRV/DiscordSRV/wiki/alerts#afkstatuschangeevent

Though this is going to be added into DiscordSRV itself as well eventually.

does this alerts feature support (if any boolean)?

commented

does this alerts feature support (if any boolean)?

What?

commented

should we talk in discord about that?

commented

like, If player has perms for example? (without permission:)

commented

I have just finished making an addon to support that. I just waiting for someone to test. I will send the link when ready.

Add support for AFK messages to DiscordSRV. What I mean is, say someone ingame does /afk, a message should show not just ingame, but also in the discord:
"%player% is now AFK." "%player% is no longer AFK." Or:
"* %player% is now AFK." "* %player% is no longer AFK." like ingame - see below.
Ingame it looks like this (with the *); maybe even have it the same in Discord?
image
(this is through essentials, alas the word essentials in the title... I think this is the most popular, and best, plugin with /afk; as well as many other useful functions)
It would be a useful function since join/leave/kill and server start/stop messages are already there.
Please add it, I'm sure many people want this: tho I couldn't find any issue posts about it yet. :)

I see your source code of your repo, quite simple to implement actually but the only issue is the Essentials' #onPlayerAfkChange event, because it fires right before the AFK toggled so I cant add #getAfkMessage method as it will return null. Perhaps you can address this?

commented

Your alerts.yml isn't quite right. You can try setting it to this (the code below) then restarting your server:

    Channel: global
    Embed:
      Color: "#869600"
      Author:
        ImageUrl: "https://crafatar.com/avatars/${#event.getAffected().getBase().getUniqueId()}?overlay"
        Name: '${#event.value ? #event.getAffected().getName() + " is AFK" : #event.getAffected().getName() + " is no longer AFK"}'```

(This single trigger handles both AFK and not-AFK)
commented

I have just finished making an addon to support that. I just waiting for someone to test. I will send the link when ready.

Add support for AFK messages to DiscordSRV. What I mean is, say someone ingame does /afk, a message should show not just ingame, but also in the discord:
"%player% is now AFK." "%player% is no longer AFK." Or:
"* %player% is now AFK." "* %player% is no longer AFK." like ingame - see below.
Ingame it looks like this (with the *); maybe even have it the same in Discord?
image
(this is through essentials, alas the word essentials in the title... I think this is the most popular, and best, plugin with /afk; as well as many other useful functions)
It would be a useful function since join/leave/kill and server start/stop messages are already there.
Please add it, I'm sure many people want this: tho I couldn't find any issue posts about it yet. :)

I see your source code of your repo, quite simple to implement actually but the only issue is the Essentials' #onPlayerAfkChange event, because it fires right before the AFK toggled so I cant add #getAfkMessage method as it will return null. Perhaps you can address this?

Yea right it is fired before afk is toggled, but you can check if player is afk or not so you can send your messagd

commented

Would just like to note that there is already a example for this kind of alert on the wiki, see https://github.com/DiscordSRV/DiscordSRV/wiki/alerts#afkstatuschangeevent
Though this is going to be added into DiscordSRV itself as well eventually.

I used this template for my server, however, the event is not triggering. If I change the trigger to /afk, it kind of works, but I get an error message. However, when I use the AfkStatusChangeEvent for the trigger, it just never triggers. Any help would be greatly appreciated!

Show the alerts file for /afk method. But the second one may be because of missing intents which will need a fork

commented

However, when I use the AfkStatusChangeEvent for the trigger, it just never triggers. Any help would be greatly appreciated!

This issue is fixed on the snapshot build https://snapshot.discordsrv.com

commented

Would just like to note that there is already a example for this kind of alert on the wiki, see https://github.com/DiscordSRV/DiscordSRV/wiki/alerts#afkstatuschangeevent

Though this is going to be added into DiscordSRV itself as well eventually.

I used this template for my server, however, the event is not triggering. If I change the trigger to /afk, it kind of works, but I get an error message. However, when I use the AfkStatusChangeEvent for the trigger, it just never triggers. Any help would be greatly appreciated!