split project into multiple files

This commit is contained in:
kageru 2018-06-03 10:40:28 +02:00
parent 0acb15b138
commit 93014d944b
Signed by untrusted user: kageru
GPG Key ID: 8282A2BEA4ADA3D2
4 changed files with 64 additions and 34 deletions

40
config.go Normal file
View File

@ -0,0 +1,40 @@
package main
import (
"os"
"encoding/json"
)
type Embed struct {
Message string
QuestionsTitle string
QuestionsText string
BugsTitle string
BugsText string
Image string
}
type Config struct {
AdminID string
ServerID string
LockedRoleID string
Token string
WelcomeChannel string
GeneralChannel string
SendWelcomeDM bool
RequireAccept bool
ComplaintReceivedMessage string
ModChannel string
WelcomeEmbed Embed
RoleCommands map[string]string
}
func readConfig() Config {
file, _ := os.Open("config.json")
conf := Config{}
json.NewDecoder(file).Decode(&conf)
file.Close()
return conf
}

0
config.json Executable file → Normal file
View File

38
main.go Executable file → Normal file
View File

@ -2,51 +2,21 @@ package main
import ( import (
"fmt" "fmt"
"encoding/json"
"strings" "strings"
"os"
"os/signal" "os/signal"
"os"
"syscall" "syscall"
"regexp" "regexp"
"log" "log"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
) )
type Embed struct {
Message string
QuestionsTitle string
QuestionsText string
BugsTitle string
BugsText string
Image string
}
type Config struct {
AdminID string
ServerID string
LockedRoleID string
Token string
WelcomeChannel string
GeneralChannel string
SendWelcomeDM bool
RequireAccept bool
ComplaintReceivedMessage string
ModChannel string
WelcomeEmbed Embed
RoleCommands map[string]string
}
var config = readConfig() var config = readConfig()
var commands []Command
func readConfig() Config { var t CommandType
file, _ := os.Open("config.json")
conf := Config{}
_ = json.NewDecoder(file).Decode(&conf)
file.Close()
return conf
}
func main() { func main() {
fmt.Println(t)
dg, err := discordgo.New("Bot " + config.Token) dg, err := discordgo.New("Bot " + config.Token)
if err != nil { if err != nil {
fmt.Println("error: ", err) fmt.Println("error: ", err)

20
types.go Normal file
View File

@ -0,0 +1,20 @@
package main
type CommandType int
const (
CommandTypePrefix CommandType = 0
CommandTypeFullMatch CommandType = 1
CommandTypeRegex CommandType = 2
)
type Command struct {
Input string
Output string
Type CommandType
OutputIsReply bool
DeleteInput bool
DMOnly bool
}