-
Notifications
You must be signed in to change notification settings - Fork 15
Boosts Events and Tags #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d71759d
d482df3
9644fd9
a724eae
dd0e2b5
f83aa0e
1bfc939
38b308a
cbdbb55
8e2ead3
c32b766
8ad95aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.denizenscript.ddiscordbot.events; | ||
|
||
import com.denizenscript.ddiscordbot.DiscordScriptEvent; | ||
import com.denizenscript.ddiscordbot.objects.DiscordGroupTag; | ||
import com.denizenscript.ddiscordbot.objects.DiscordUserTag; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import net.dv8tion.jda.api.events.guild.update.GuildUpdateBoostCountEvent; | ||
|
||
public class DiscordUpdateBoostCountEvent extends DiscordScriptEvent { | ||
|
||
// <--[event] | ||
// @Events | ||
// discord boosts count changes | ||
// | ||
// @Switch for:<bot> to only process the event for a specified Discord bot. | ||
// @Switch group:<group_id> to only process the event for a specified Discord group. | ||
// | ||
// @Triggers when the boosts count of the server changes | ||
// | ||
// @Plugin dDiscordBot | ||
// | ||
// @Group Discord | ||
// | ||
// @Context | ||
// <context.bot> returns the relevant DiscordBotTag. | ||
// <context.group> returns the DiscordGroupTag whose boost count changed. | ||
// <context.new_count> returns the group's new new amount of boosts. | ||
// <context.old_count> returns the group's old amount of boosts. | ||
// --> | ||
|
||
public static DiscordUpdateBoostCountEvent instance; | ||
|
||
public DiscordUpdateBoostCountEvent() { | ||
instance = this; | ||
registerCouldMatcher("discord boosts count changes"); | ||
registerSwitches("group"); | ||
} | ||
|
||
public GuildUpdateBoostCountEvent getEvent() { | ||
return (GuildUpdateBoostCountEvent) event; | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if (!tryGuild(path, getEvent().getGuild())) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "group" -> new DiscordGroupTag(botID, getEvent().getGuild()); | ||
case "new_count" -> new DiscordGroupTag(botID, getEvent().getNewBoostCount()); | ||
case "old_count" -> new DiscordGroupTag(botID, getEvent().getOldBoostCount()); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ public static void register() { | |
// @returns ElementTag(Boolean) | ||
// @plugin dDiscordBot | ||
// @description | ||
// Returns a boolean indicating whether the user is a bot. | ||
// Returns whether the user is a bot or not. | ||
// --> | ||
tagProcessor.registerTag(ElementTag.class, "is_bot", (attribute, object) -> { | ||
if (object.getUserForTag(attribute) == null) { | ||
|
@@ -240,6 +240,21 @@ public static void register() { | |
return new ElementTag(object.getUser().isBot()); | ||
}); | ||
|
||
// <--[tag] | ||
// @attribute <DiscordUserTag.is_boosting[<group>]> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't discord add an unremovable role for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ie most of these tags and the event can be replaced by just scripts checking the role There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The role can be renamed, this tag comes as an reliable alternative mean without using a RoleTag based input. |
||
// @returns ElementTag(Boolean) | ||
// @plugin dDiscordBot | ||
// @description | ||
// Return whether the user is boosting the specified group or not. | ||
// --> | ||
tagProcessor.registerTag(ElementTag.class, DiscordGroupTag.class, "is_boosting", (attribute, object, group) -> { | ||
if (object.getUserForTag(attribute) == null) { | ||
return new ElementTag(false); | ||
} | ||
Member member = group.getGuild().getMember(object.getUser()); | ||
return new ElementTag(member.isBoosting()); | ||
}); | ||
|
||
// <--[tag] | ||
// @attribute <DiscordUserTag.avatar_url> | ||
// @returns ElementTag | ||
|
@@ -457,7 +472,7 @@ public static void register() { | |
// @returns ListTag | ||
// @plugin dDiscordBot | ||
// @description | ||
// Returns a list of permissions that the user has in a certain group. You can get a list of possible outputs here: <@link url https://ci.dv8tion.net/job/JDA5/javadoc/net/dv8tion/jda/api/Permission.html> | ||
// Returns a list of permissions that the user has in a certain group. You can get a list of possible outputs here: <@link url https://docs.jda.wiki/net/dv8tion/jda/api/Permission.html> | ||
// --> | ||
tagProcessor.registerTag(ListTag.class, "permissions", (attribute, object) -> { | ||
if (!attribute.hasParam()) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.