Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
add screenshare module, add @NotNullable to old modules before build …
Browse files Browse the repository at this point in the history
…tools update
  • Loading branch information
CremBluRay committed Jul 22, 2019
1 parent ec0202c commit e7689ed
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import discord4j.core.object.util.PermissionSet;
import reactor.core.publisher.Mono;

import javax.validation.constraints.NotNull;

public final class ModuleBan extends Module {
public ModuleBan() {
super(new ModuleInfo.Builder(ModuleBan.class)
Expand All @@ -16,7 +18,7 @@ public ModuleBan() {
}

@Override
public void invoke(CommandContext ctx) {
public void invoke(@NotNull CommandContext ctx) {
//Check for args
try{
ctx.getArgs().get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import discord4j.core.object.util.PermissionSet;
import reactor.core.publisher.Mono;

import javax.validation.constraints.NotNull;

public final class ModuleMute extends Module {
public ModuleMute() {
super(new ModuleInfo.Builder(ModuleMute.class)
Expand All @@ -16,7 +18,7 @@ public ModuleMute() {
}

@Override
public void invoke(CommandContext ctx) {
public void invoke(@NotNull CommandContext ctx) {
//Check for args
try{
ctx.getArgs().get(0);
Expand Down
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);
}
}
}

0 comments on commit e7689ed

Please sign in to comment.