Skip to content
Snippets Groups Projects
Commit f52b4946 authored by Reviath's avatar Reviath
Browse files

Added Makefile

parent 974d7af3
Branches
Tags
No related merge requests found
/build
\ No newline at end of file
Makefile 0 → 100644
.NOTPARALLEL: static-arg nowindowsgui build start
SHELL = sh
all: build
static: static-arg build
run: nowindowsgui build start
.PHONY: static-arg
static-arg:
$(eval STATIC_LDFLAGS = -extldflags "-static")
.PHONY: nowindowsgui
nowindowsgui:
$(eval WINDOW_LDFLAGS = )
.PHONY: build
build:
@echo "Building ..."
@go build -tags=jsoniter -ldflags="$(LDFLAGS) $(STATIC_LDFLAGS) $(WINDOW_LDFLAGS)" -o build/remiliascarlet$(shell go env GOEXE) $$PWD/main.go
.PHONY: start
start:
@./build/remiliascarlet
......@@ -8,6 +8,7 @@ import (
"net/http"
"time"
multiplexer "git.randomchars.net/Reviath/RemiliaScarlet/Multiplexer"
"git.randomchars.net/Reviath/RemiliaScarlet/config"
"github.com/bwmarrin/discordgo"
"github.com/gin-gonic/gin"
......@@ -89,6 +90,25 @@ func Listen(session *discordgo.Session) {
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/")
} else {
var token = &oauth2.Token{}
jsoniter.UnmarshalFromString(fmt.Sprint(val), token)
res, err := conf.Client(context.TODO(), token).Get("https://discordapp.com/api/v8/users/@me")
if err != nil || res.StatusCode != 200 {
fmt.Println("An error occurred on api: " + err.Error())
return
}
var user discordgo.User
data, _ := ioutil.ReadAll(res.Body)
err = json.Unmarshal(data, &user)
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/")
}
if !multiplexer.CheckAdministratorPermission(session, user.ID, guild.SystemChannelID) {
fmt.Fprintf(c.Writer, "Unauthorized")
return
}
fmt.Fprintf(c.Writer, guild.Name)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment