-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from KittyBot-Org/development
fix for checking if user is in channel when using play cmd
- Loading branch information
Showing
12 changed files
with
123 additions
and
29 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
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
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
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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/de/kittybot/kittybot/web/dev/GetDevRoute.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,36 @@ | ||
package de.kittybot.kittybot.web.dev; | ||
|
||
import de.kittybot.kittybot.modules.MusicModule; | ||
import de.kittybot.kittybot.modules.WebModule; | ||
import de.kittybot.kittybot.objects.module.Modules; | ||
import de.kittybot.kittybot.objects.music.MusicPlayer; | ||
import de.kittybot.kittybot.utils.Config; | ||
import io.javalin.http.Context; | ||
import io.javalin.http.ForbiddenResponse; | ||
import io.javalin.http.Handler; | ||
import net.dv8tion.jda.api.utils.data.DataArray; | ||
import net.dv8tion.jda.api.utils.data.DataObject; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
public class GetDevRoute implements Handler{ | ||
|
||
private final Modules modules; | ||
|
||
public GetDevRoute(Modules modules){ | ||
this.modules = modules; | ||
} | ||
|
||
@Override | ||
public void handle(@NotNull Context ctx){ | ||
var userId = this.modules.get(WebModule.class).getUserId(ctx); | ||
if(!Config.DEV_IDS.contains(userId)){ | ||
throw new ForbiddenResponse("Only bot devs have access to this"); | ||
} | ||
var json = DataObject.empty() | ||
.put("music_players", DataArray.fromCollection(this.modules.get(MusicModule.class).getPlayers().stream().map(MusicPlayer::toJSON).collect(Collectors.toList()))); | ||
WebModule.ok(ctx, json.toData()); | ||
} | ||
|
||
} |
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