Skip to content

Commit

Permalink
tunebot repo standardisation
Browse files Browse the repository at this point in the history
  • Loading branch information
bronson-g committed Jul 27, 2023
1 parent 69b867f commit 33ded78
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 Bronson Graansma, Christopher Beimers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# tune-bot discord
# tune-bot bot
Discord bot to interface with tunebot and play user playlists in the voice channel.

## How to Build Locally
This requires the Discord bot token which is only accessible from the Discord [Developer Portal](https://discord.com/developers), under `Applications > TuneBot > Bot > "Reset Token"`. The token can only be seen when it is first generated, and it available as the environment variable DISCORD_TOKEN. You must also ensure the [database](https://www.github.com/tune-bot/database) is running for local database development, or have a valid host and credentials to the production tunebot server.
This requires the Discord bot token which is only accessible from the Discord [Developer Portal](https://discord.com/developers), under `Applications > TuneBot > Bot > "Reset Token"`. The token can only be seen when it is first generated, and it available as the environment variable DISCORD_TOKEN. You must also ensure the [core](https://www.github.com/tune-bot/core) is running for local database development, or have a valid host and credentials to the production tunebot server.

```
export DISCORD_TOKEN=<token>
git clone github.com/tune-bot/discord
cd discord
git clone github.com/tune-bot/bot
cd bot
go run .
```
6 changes: 3 additions & 3 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/bwmarrin/discordgo"

"github.com/tune-bot/database"
"github.com/tune-bot/core"
)

// Wrap a Discord session and other bot data
Expand Down Expand Up @@ -62,7 +62,7 @@ func (b *Bot) start() {
log.Println("Started Discord session")

// Open a connection to the database
if err = database.Connect(); err != nil {
if err = core.Connect(); err != nil {
log.Fatal(err)
return
}
Expand All @@ -76,7 +76,7 @@ func (b *Bot) start() {
go func() {
defer func() {
log.Println("Ending Discord session")
database.Disconnect()
core.Disconnect()
b.Close()
wg.Done()
}()
Expand Down
10 changes: 5 additions & 5 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/bwmarrin/discordgo"
"github.com/tune-bot/database"
"github.com/tune-bot/core"
)

// A command callback takes a reference to the bot singleton and
Expand Down Expand Up @@ -40,11 +40,11 @@ func cmdLink(b *Bot, m *discordgo.MessageCreate, args []string) (string, reactio
return rsp, nil
}

discordUser := database.Discord{Name: m.Author.Username}
tunebotUser := database.User{Username: args[0]}
discordUser := core.Discord{Name: m.Author.Username}
tunebotUser := core.User{Username: args[0]}

// Check if the Tunebot user exists before trying to link a Discord account to it
if _, err := database.FindUser(tunebotUser.Username); err != nil {
if _, err := core.FindUser(tunebotUser.Username); err != nil {
return err.Error(), nil
}

Expand All @@ -55,7 +55,7 @@ func cmdLink(b *Bot, m *discordgo.MessageCreate, args []string) (string, reactio
}

// If there isn't an account linked, GetUser will return a specific error
if err == database.ErrNoDiscordUser {
if err == core.ErrNoDiscordUser {
rsp = fmt.Sprintf("%s\nTo link your Discord account, react to this message", err)
return rsp, linkUserCallback
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/bwmarrin/discordgo v0.27.1
github.com/tune-bot/database v1.1.8
github.com/tune-bot/core v1.2.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/tune-bot/database v1.1.8 h1:kfVl3mnLxXfCo1/DIYPDJ+uoOqt9OnSX1k0WEgy8wtk=
github.com/tune-bot/database v1.1.8/go.mod h1:G4ZHaIWI7HPxgYBa7T2SPfK6PKda3/2dCQ1X4w4E12k=
github.com/tune-bot/core v1.2.0 h1:UaTXZehbRES8WK+DDCptSw2vbj+TZ6IHr2PB+daRe2Y=
github.com/tune-bot/core v1.2.0/go.mod h1:V60L7jFC9PErr2jf0a1+IT8hiu0sobO2K7ltl0ruNb0=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions reaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/bwmarrin/discordgo"
"github.com/tune-bot/database"
"github.com/tune-bot/core"
)

// Callbacks for reactions on bot messages
Expand All @@ -24,12 +24,12 @@ func linkUserCallback(_ *Bot, r *discordgo.MessageReactionAdd, args []string) st
var userId string
var err error

if userId, err = database.FindUser(args[0]); err != nil {
if userId, err = core.FindUser(args[0]); err != nil {
return err.Error()
}
discordUser := database.Discord{
Name: r.Member.User.Username,
}

discordUser := core.Discord{
Name: r.Member.User.Username,
UserId: userId,
}

Expand Down

0 comments on commit 33ded78

Please sign in to comment.