-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swap TimeTag property to modern Extension
- Loading branch information
1 parent
09e13b5
commit bf7b023
Showing
3 changed files
with
31 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/denizenscript/ddiscordbot/properties/DiscordTimeTagExtensions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.denizenscript.ddiscordbot.properties; | ||
|
||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.core.TimeTag; | ||
|
||
public class DiscordTimeTagExtensions { | ||
|
||
public static void register() { | ||
|
||
// <--[tag] | ||
// @attribute <TimeTag.format_discord[(<style>)]> | ||
// @returns ElementTag | ||
// @group properties | ||
// @Plugin dDiscordBot | ||
// @description | ||
// Returns the time formatted for display on Discord, optionally using the specified style from <@link url https://discord.com/developers/docs/reference#message-formatting-timestamp-styles>. | ||
// For example: <util.time_now.format_discord> or <util.time_now.format_discord[R]> | ||
// Note that style input, if used, is case sensitive. | ||
// --> | ||
TimeTag.tagProcessor.registerStaticTag(ElementTag.class, "format_discord", (attribute, time) -> { | ||
long stamp = time.millis() / 1000; | ||
if (attribute.hasParam()) { | ||
return new ElementTag("<t:" + stamp + ":" + attribute.getParam() + ">"); | ||
} | ||
return new ElementTag("<t:" + stamp + ">"); | ||
}); | ||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
src/main/java/com/denizenscript/ddiscordbot/properties/DiscordTimeTagProperties.java
This file was deleted.
Oops, something went wrong.