mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-10 09:02:49 +00:00
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
config.json
|
config.json
|
||||||
dist/config.json
|
dist
|
||||||
dist/sounds
|
|
||||||
node_modules
|
node_modules
|
||||||
yarn-error*
|
yarn-error*
|
||||||
|
|||||||
@@ -6,14 +6,10 @@ import Wrapper from './Wrapper';
|
|||||||
import Soundboard from './pages/Soundboard/Soundboard';
|
import Soundboard from './pages/Soundboard/Soundboard';
|
||||||
import NotFound from './pages/NotFound/NotFound';
|
import NotFound from './pages/NotFound/NotFound';
|
||||||
|
|
||||||
//pages
|
|
||||||
import Home from './pages/Home/Home';
|
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Router history={browserHistory}>
|
<Router history={browserHistory}>
|
||||||
<Route path="/" component={Wrapper}>
|
<Route path="/" component={Wrapper}>
|
||||||
<IndexRoute component={Home}/>
|
<IndexRoute component={Soundboard}/>
|
||||||
<Route path="/soundboard" component={Soundboard}/>
|
|
||||||
<Route path="*" component={NotFound}/>
|
<Route path="*" component={NotFound}/>
|
||||||
</Route>
|
</Route>
|
||||||
</Router>
|
</Router>
|
||||||
|
|||||||
@@ -8,12 +8,8 @@ export default class Navbar extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="Navbar">
|
<div className="Navbar">
|
||||||
<div className="Navbar__header">GoBot</div>
|
<div className="Navbar__header">Sound<br/>Bot</div>
|
||||||
<Link to="/" className="Navbar__item" onlyActiveOnIndex activeClassName="Navbar__item--active">Home</Link>
|
<Link to="/" className="Navbar__item" onlyActiveOnIndex activeClassName="Navbar__item--active">Soundboard</Link>
|
||||||
<Link to="/soundboard" className="Navbar__item" activeClassName="Navbar__item--active">Soundboard</Link>
|
|
||||||
<div className="link">
|
|
||||||
<a href="https://discordapp.com/invite/0Z2tzxKECEj2BHwj" target="_blank">Join the discord</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -21,4 +17,4 @@ export default class Navbar extends React.Component {
|
|||||||
|
|
||||||
Navbar.propTypes = {
|
Navbar.propTypes = {
|
||||||
children: React.PropTypes.node,
|
children: React.PropTypes.node,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,14 +12,6 @@
|
|||||||
border-right: 1px solid darken($gray2, 2%);
|
border-right: 1px solid darken($gray2, 2%);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
|
|
||||||
.link {
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: flex-end;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.Navbar__header {
|
.Navbar__header {
|
||||||
@@ -28,6 +20,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
background-color: $primaryBlue;
|
background-color: $primaryBlue;
|
||||||
border-bottom: 1px solid $gray3;
|
border-bottom: 1px solid $gray3;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import './Home.scss';
|
|
||||||
|
|
||||||
export default class Home extends React.Component {
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div className="Home">
|
|
||||||
<div className="Card">
|
|
||||||
<div className="Card__header">
|
|
||||||
GoBot Early Access Pre Pre Alpha
|
|
||||||
</div>
|
|
||||||
<p>This application is a work in progress.</p>
|
|
||||||
<p>Check out the source code on
|
|
||||||
<a href="https://github.com/mgerb/GoBot" target="_blank"> GitHub
|
|
||||||
<i className="fa fa-github" aria-hidden="true"></i>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
@import "../../scss/variables";
|
|
||||||
|
|
||||||
.Home {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
@@ -77,6 +77,18 @@ export default class Soundboard extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div className="Soundboard">
|
<div className="Soundboard">
|
||||||
<div className="column">
|
<div className="column">
|
||||||
|
<div className="Card">
|
||||||
|
<div className="Card__header">
|
||||||
|
Discord Sound Bot
|
||||||
|
</div>
|
||||||
|
<p>Drag and drop files to upload. The sounds can then be played in discord by typing the commands below.</p>
|
||||||
|
<p>Check out the source code on
|
||||||
|
<a href="https://github.com/mgerb/GoBot" target="_blank"> GitHub
|
||||||
|
<i className="fa fa-github" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p>Follow the readme to set up your own bot!</p>
|
||||||
|
</div>
|
||||||
<SoundList ref="SoundList"/>
|
<SoundList ref="SoundList"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ body {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
border: 1px solid $gray3;
|
border: 1px solid $gray3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
dist/GoBot-linux
vendored
BIN
dist/GoBot-linux
vendored
Binary file not shown.
7
dist/config.template.json
vendored
7
dist/config.template.json
vendored
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"Token": "",
|
|
||||||
"BotPrefix": "#",
|
|
||||||
"SoundsPath": "./sounds/",
|
|
||||||
"UploadPassword": "",
|
|
||||||
"ServerAddr": ":80"
|
|
||||||
}
|
|
||||||
5
dist/index.html
vendored
5
dist/index.html
vendored
@@ -1,5 +0,0 @@
|
|||||||
<html><head><link href="/static/app.51a9064c6fa89f0c8861.css" rel="stylesheet"></head>
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script type="text/javascript" src="/static/manifest.51a9064c6fa89f0c8861.js"></script><script type="text/javascript" src="/static/vendor.51a9064c6fa89f0c8861.js"></script><script type="text/javascript" src="/static/app.51a9064c6fa89f0c8861.js"></script></body>
|
|
||||||
</html>
|
|
||||||
4
dist/static/app.51a9064c6fa89f0c8861.css
vendored
4
dist/static/app.51a9064c6fa89f0c8861.css
vendored
File diff suppressed because one or more lines are too long
3
dist/static/app.51a9064c6fa89f0c8861.js
vendored
3
dist/static/app.51a9064c6fa89f0c8861.js
vendored
File diff suppressed because one or more lines are too long
BIN
dist/static/fontawesome-webfont.eot
vendored
BIN
dist/static/fontawesome-webfont.eot
vendored
Binary file not shown.
2671
dist/static/fontawesome-webfont.svg
vendored
2671
dist/static/fontawesome-webfont.svg
vendored
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 434 KiB |
BIN
dist/static/fontawesome-webfont.ttf
vendored
BIN
dist/static/fontawesome-webfont.ttf
vendored
Binary file not shown.
BIN
dist/static/fontawesome-webfont.woff
vendored
BIN
dist/static/fontawesome-webfont.woff
vendored
Binary file not shown.
BIN
dist/static/fontawesome-webfont.woff2
vendored
BIN
dist/static/fontawesome-webfont.woff2
vendored
Binary file not shown.
1
dist/static/manifest.51a9064c6fa89f0c8861.js
vendored
1
dist/static/manifest.51a9064c6fa89f0c8861.js
vendored
@@ -1 +0,0 @@
|
|||||||
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,c,i){for(var u,a,f,s=0,l=[];s<t.length;s++)a=t[s],o[a]&&l.push(o[a][0]),o[a]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(n&&n(t,c,i);l.length;)l.shift()();if(i)for(s=0;s<i.length;s++)f=r(r.s=i[s]);return f};var t={},o={2:0};r.e=function(e){function n(){c.onerror=c.onload=null,clearTimeout(i);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,r.nc&&c.setAttribute("nonce",r.nc),c.src=r.p+"/static/"+e+".51a9064c6fa89f0c8861.js";var i=setTimeout(n,12e4);c.onerror=c.onload=n;var u=new Promise(function(r,n){o[e]=[r,n]});return o[e][2]=u,t.appendChild(c),u},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r.oe=function(e){throw console.error(e),e}}([]);
|
|
||||||
24
dist/static/vendor.51a9064c6fa89f0c8861.js
vendored
24
dist/static/vendor.51a9064c6fa89f0c8861.js
vendored
File diff suppressed because one or more lines are too long
16
makefile
16
makefile
@@ -1,20 +1,18 @@
|
|||||||
run:
|
run:
|
||||||
go run ./server/main.go
|
go run ./server/main.go
|
||||||
|
|
||||||
linux:
|
install:
|
||||||
go build -o ./dist/GoBot-linux ./server/main.go
|
go get ./server && yarn install
|
||||||
|
|
||||||
mac:
|
build:
|
||||||
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o ./dist/GoBot-mac ./server/main.go
|
go build -o ./dist/GoBot ./server/main.go
|
||||||
|
|
||||||
windows:
|
|
||||||
CGO_ENABLED=1 GOOS=windows GOARCH=386 go build -o ./dist/GoBot-windows.exe ./server/main.go
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf ./dist
|
rm -rf ./dist
|
||||||
|
|
||||||
copyfiles:
|
copyfiles:
|
||||||
cp config.template.json ./dist/config.template.json
|
cp config.template.json ./dist/config.template.json
|
||||||
|
cp ffmpeg ./dist/ffmpeg
|
||||||
|
|
||||||
all: linux copyfiles
|
all: install build copyfiles
|
||||||
yarn run build
|
yarn run build
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "A seed for a simple react application",
|
"description": "A seed for a simple react application",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack -p --progress --colors",
|
"build": "webpack -p --progress --colors",
|
||||||
"dev": "webpack-dev-server --inline --hot --history-api-fallback",
|
"dev": "webpack --watch",
|
||||||
"c9": "webpack-dev-server --host 0.0.0.0 --port 8080 --inline --hot --history-api-fallback"
|
"c9": "webpack-dev-server --host 0.0.0.0 --port 8080 --inline --hot --history-api-fallback"
|
||||||
},
|
},
|
||||||
"author": "Mitchell Gerber",
|
"author": "Mitchell Gerber",
|
||||||
|
|||||||
40
readme.md
40
readme.md
@@ -1,18 +1,34 @@
|
|||||||
# GoBot
|
# Discord Sound Bot
|
||||||
|
|
||||||
My experimental Discord bot
|
This is a soundboard bot for discord. The back end is in GoLang and the front end uses React.
|
||||||
|
|
||||||
### Cross Compiling
|
<img src="http://i.imgur.com/jtAyJZ1.png"/>
|
||||||
The gopus library uses the CGO package, therefore building both Mac and Linux require `CGO_ENABLED=1`.
|
|
||||||
|
|
||||||
> Work in progress
|
## Dependencies
|
||||||
|
- Go
|
||||||
|
- Yarn (or npm - makefile will need to be adjusted)
|
||||||
|
- make
|
||||||
|
|
||||||
Other libraries are needed in order for CGO work properly cross platform.
|
## How to use
|
||||||
|
|
||||||
```
|
- Make sure dependencies are installed
|
||||||
sudo apt-get install gcc-multilib
|
- `make all`
|
||||||
apt-get install libpango1.0
|
- Rename the `config.template.json` to `config.json`
|
||||||
```
|
- add configurations to `config.json`
|
||||||
|
- run the executable
|
||||||
|
- open a browser `localhost:<port>`
|
||||||
|
- upload files
|
||||||
|
- success!
|
||||||
|
|
||||||
This are some packages I came across as suggestions after a little browsing. Doesn't seem to be working currently.
|
### NOTE
|
||||||
This is something I need to investigate more on in the future.
|
|
||||||
|
If you get a permissions error with ffmpeg:
|
||||||
|
`sudo chmod +x dist/ffmpeg`
|
||||||
|
|
||||||
|
Sounds are stored in the `dist/sounds` directory. You may copy files directly to this folder rather than uploading through the site.
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
I've only compiled and run this on linux, but it should work on windows with little changes.
|
||||||
|
An ffmpeg executable is required. The linux executable is included.
|
||||||
|
If running on windows ffmpeg.exe must be downloaded.
|
||||||
|
Check line 116 in server/bothandlers/sounds.go
|
||||||
|
|||||||
@@ -113,8 +113,9 @@ func loadFile(fileName string) error {
|
|||||||
|
|
||||||
fmt.Println("Loading file: " + fname + fextension)
|
fmt.Println("Loading file: " + fname + fextension)
|
||||||
|
|
||||||
|
// TODO - check if windows and use "./ffmpeg.exe" - change this if you wish to run on windows
|
||||||
// use ffmpeg to convert file into a format we can use
|
// use ffmpeg to convert file into a format we can use
|
||||||
cmd := exec.Command("ffmpeg", "-i", config.Config.SoundsPath+fname+fextension, "-f", "s16le", "-ar", strconv.Itoa(frameRate), "-ac", strconv.Itoa(channels), "pipe:1")
|
cmd := exec.Command("./ffmpeg", "-i", config.Config.SoundsPath+fname+fextension, "-f", "s16le", "-ar", strconv.Itoa(frameRate), "-ac", strconv.Itoa(channels), "pipe:1")
|
||||||
|
|
||||||
ffmpegout, err := cmd.StdoutPipe()
|
ffmpegout, err := cmd.StdoutPipe()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user