-
-
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.
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 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
43 changes: 43 additions & 0 deletions
43
src/main/java/info/itsthesky/disky/elements/getters/GetAudioChannel.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,43 @@ | ||
package info.itsthesky.disky.elements.getters; | ||
|
||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Since; | ||
import info.itsthesky.disky.core.Bot; | ||
import jdk.jfr.Name; | ||
import net.dv8tion.jda.api.entities.AudioChannel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@Name("Get Audio Channel") | ||
@Description({"This is an utility expression.", | ||
"It will returns an Audio Channel out of the provided ID.", | ||
"It will returns either the voice or stage channel corresponding to the provided ID.", | ||
"This expression cannot be changed."}) | ||
@Examples("audio channel with id \"000\"") | ||
@Since("4.0.0") | ||
public class GetAudioChannel extends BaseGetterExpression<AudioChannel> { | ||
|
||
static { | ||
register( | ||
GetAudioChannel.class, | ||
AudioChannel.class, | ||
"audio channel" | ||
); | ||
} | ||
|
||
@Override | ||
protected AudioChannel get(String id, Bot bot) { | ||
final AudioChannel voice = bot.getInstance().getVoiceChannelById(id); | ||
return voice == null ? bot.getInstance().getStageChannelById(id) : voice; | ||
} | ||
|
||
@Override | ||
public String getCodeName() { | ||
return "audio channel"; | ||
} | ||
|
||
@Override | ||
public @NotNull Class<? extends AudioChannel> getReturnType() { | ||
return AudioChannel.class; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/info/itsthesky/disky/elements/getters/GetMessageChannel.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,55 @@ | ||
package info.itsthesky.disky.elements.getters; | ||
|
||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Since; | ||
import info.itsthesky.disky.core.Bot; | ||
import jdk.jfr.Name; | ||
import net.dv8tion.jda.api.entities.AudioChannel; | ||
import net.dv8tion.jda.api.entities.BaseGuildMessageChannel; | ||
import net.dv8tion.jda.api.entities.GuildMessageChannel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@Name("Get Message Channel") | ||
@Description({"This is an utility expression.", | ||
"It will returns a Message Channel (text, news or thread) out of the provided ID.", | ||
"This expression cannot be changed."}) | ||
@Examples("message channel with id \"000\"") | ||
@Since("4.0.0") | ||
public class GetMessageChannel extends BaseGetterExpression<GuildMessageChannel> { | ||
|
||
static { | ||
register( | ||
GetMessageChannel.class, | ||
GuildMessageChannel.class, | ||
"message channel" | ||
); | ||
} | ||
|
||
@Override | ||
protected GuildMessageChannel get(String id, Bot bot) { | ||
final GuildMessageChannel text = bot.getInstance().getTextChannelById(id); | ||
if (text != null) | ||
return text; | ||
|
||
final GuildMessageChannel news = bot.getInstance().getNewsChannelById(id); | ||
if (news != null) | ||
return news; | ||
|
||
final GuildMessageChannel thread = bot.getInstance().getThreadChannelById(id); | ||
if (thread != null) | ||
return thread; | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public String getCodeName() { | ||
return "message channel"; | ||
} | ||
|
||
@Override | ||
public @NotNull Class<? extends GuildMessageChannel> getReturnType() { | ||
return GuildMessageChannel.class; | ||
} | ||
} |