This repository has been archived by the owner on Nov 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add screenshare module, add @NotNullable to old modules before build …
…tools update
- Loading branch information
CremBluRay
committed
Jul 22, 2019
1 parent
ec0202c
commit e7689ed
Showing
3 changed files
with
38 additions
and
2 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
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
32 changes: 32 additions & 0 deletions
32
src/main/java/com/github/coleb1911/ghost2/commands/modules/utility/ModuleScreenshare.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,32 @@ | ||
package com.github.coleb1911.ghost2.commands.modules.utility; | ||
|
||
import com.github.coleb1911.ghost2.commands.meta.CommandContext; | ||
import com.github.coleb1911.ghost2.commands.meta.Module; | ||
import com.github.coleb1911.ghost2.commands.meta.ModuleInfo; | ||
import discord4j.core.object.VoiceState; | ||
import discord4j.core.object.util.Snowflake; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.Optional; | ||
|
||
public final class ModuleScreenshare extends Module { | ||
|
||
private static final String NOVOICE = "You are not in a voice channel. Please join a voice channel to use the `screenshare` command."; | ||
|
||
public ModuleScreenshare() { | ||
super(new ModuleInfo.Builder(ModuleScreenshare.class) | ||
.withName("screenshare") | ||
.withDescription("Generates a screenshare link.")); | ||
} | ||
|
||
@Override | ||
public void invoke(@NotNull CommandContext ctx) { | ||
// Check if user is connected to a voice channel | ||
Optional<Snowflake> state = ctx.getInvoker().getVoiceState().map(VoiceState::getChannelId).block(); | ||
if(state.isPresent()) | ||
ctx.reply("https://discordapp.com/channels/" + ctx.getGuild().getId().asLong() + "/" + ctx.getInvoker().getVoiceState().block().getChannelId().get().asLong()); | ||
else { | ||
ctx.reply(NOVOICE); | ||
} | ||
} | ||
} |