From 89b6d898904c84b49e2ab8f2c4d200e796f282f1 Mon Sep 17 00:00:00 2001 From: Mitchell Date: Sun, 15 Apr 2018 15:28:12 -0500 Subject: [PATCH] expanded permissions functionality - added packr for bundling static assets --- client/app/components/Navbar/Navbar.tsx | 12 +-- client/app/pages/stats/stats.tsx | 5 +- config.template.json | 1 + makefile | 4 +- readme.md | 93 +++++++++++------ server/bothandlers/sounds.go | 127 ++++++++++++------------ server/config/config.go | 1 + server/webserver/middleware/jwt.go | 67 ++++++++++--- server/webserver/server.go | 8 +- 9 files changed, 196 insertions(+), 122 deletions(-) diff --git a/client/app/components/Navbar/Navbar.tsx b/client/app/components/Navbar/Navbar.tsx index 0aa6d70..ccb6ed4 100644 --- a/client/app/components/Navbar/Navbar.tsx +++ b/client/app/components/Navbar/Navbar.tsx @@ -4,15 +4,9 @@ import jwt_decode from 'jwt-decode'; import { StorageService } from '../../services'; import './Navbar.scss'; -let oauthUrl: string; +const baseUrl = window.location.origin + '/oauth'; -if (!process.env.NODE_ENV) { - // dev - oauthUrl = `https://discordapp.com/api/oauth2/authorize?client_id=410818759746650140&redirect_uri=https%3A%2F%2Flocalhost%2Foauth&response_type=code&scope=identify%20guilds`; -} else { - // prod - oauthUrl = `https://discordapp.com/api/oauth2/authorize?client_id=271998875802402816&redirect_uri=https%3A%2F%2Fcashdiscord.com%2Foauth&response_type=code&scope=identify%20guilds%20email`; -} +const oauthUrl = `https://discordapp.com/api/oauth2/authorize?client_id=410818759746650140&redirect_uri=${baseUrl}&response_type=code&scope=identify%20guilds`; interface Props {} @@ -47,7 +41,7 @@ export class Navbar extends React.Component { render() { return (
-
Cash
+
Sound Bot
Home diff --git a/client/app/pages/stats/stats.tsx b/client/app/pages/stats/stats.tsx index 7358438..88d5336 100644 --- a/client/app/pages/stats/stats.tsx +++ b/client/app/pages/stats/stats.tsx @@ -34,6 +34,7 @@ export class Stats extends Component { return { username: k, count: v }; }) .orderBy(v => v.count, 'desc') + .slice(0, 10) .value(); this.setState({ data }); @@ -61,8 +62,8 @@ export class Stats extends Component { return (
-
Shitposts
- +
Posts containing links
+
); diff --git a/config.template.json b/config.template.json index 3d3e01d..7af28fd 100644 --- a/config.template.json +++ b/config.template.json @@ -7,6 +7,7 @@ "bot_prefix": "#", "admin_emails": ["mail@example.com"], + "mod_emails": ["mail@example.com"], "jwt_key": "", "server_addr": "0.0.0.0:80", diff --git a/makefile b/makefile index aad88a3..d9fe8dd 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,7 @@ install: go get && cd client && npm install build-server: - go build -o bot ./main.go + packr build -o bot ./main.go && packr install build-client: cd client && npm run build @@ -13,4 +13,4 @@ build-client: clean: rm -rf bot ./dist -all: install build-server build-client +all: install build-client build-server diff --git a/readme.md b/readme.md index d757ce7..c7f5cb4 100644 --- a/readme.md +++ b/readme.md @@ -1,51 +1,88 @@ # Discord Sound Bot -This is a soundboard bot for discord. The back end is in GoLang and the front end uses React. +A soundboard bot for discord with a Go back end and React front end. - +![Image](https://i.imgur.com/BCoLAuK.png) ## How to use -NOTE: Currently the binaries in the release package only run on linux. Check them out [here](https://github.com/mgerb/go-discord-bot/releases) +* [Download latest release here](https://github.com/mgerb/go-discord-bot/releases) +* Install [youtube-dl](https://github.com/rg3/youtube-dl/blob/master/README.md#installation) +* Install [ffmpeg](https://www.ffmpeg.org/download.html) +* edit your config.json file +* run the executable -- download bot.zip and extract everything -- rename config.template.json to config.json -- add your bot token and preferred upload password (leave as is for no password) -- run the bot with `./bot` (you may need to use sudo if you leave it on port 80) +### Commands -## Flags +* `clip` - clips the past minute of audio +* `summon` - summons the bot to your current channel +* `dismiss` - dismisses the bot from the server +* `