ClaptrapBot/src/main/java/net/Broken/webView/MusicWebView.java

29 lines
1.1 KiB
Java
Raw Normal View History

2017-12-22 19:20:26 +01:00
package net.Broken.webView;
2018-05-14 11:57:05 +02:00
import net.Broken.MainBot;
import net.Broken.Tools.SettingsUtils;
2018-05-14 11:57:05 +02:00
import net.dv8tion.jda.core.entities.Guild;
2017-12-22 19:20:26 +01:00
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
2018-05-14 11:57:05 +02:00
import org.springframework.web.bind.annotation.CookieValue;
2017-12-22 19:20:26 +01:00
import org.springframework.web.bind.annotation.RequestMapping;
2018-02-28 17:59:09 +01:00
/**
* Web page controller for /music page
*/
2017-12-22 19:20:26 +01:00
@Controller
public class MusicWebView {
@RequestMapping("/music")
public String music(Model model, @CookieValue(value = "guild", defaultValue = "1") String guildId, @CookieValue(value = "token", defaultValue = "1") String token){
2018-05-14 11:57:05 +02:00
Guild guild = MainBot.jda.getGuildById(guildId);
if(guild != null)
model.addAttribute("guild_name", guild.getName());
else
model.addAttribute("guild_name", "");
2018-09-10 14:53:56 +02:00
model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
model.addAttribute("isAdmin", SettingsUtils.getInstance().checkPermission(token, guildId));
2018-05-14 11:57:05 +02:00
2018-03-06 16:26:40 +01:00
return CheckPage.getPageIfReady("music");
2017-12-22 19:20:26 +01:00
}
}