Compare commits
No commits in common. "ebcfe54cf0276984636f0ddde3c00ed935736b06" and "2e12ff158d4c28df06fa33504bceeb4faa342a16" have entirely different histories.
ebcfe54cf0
...
2e12ff158d
5 changed files with 6 additions and 77 deletions
|
@ -1,49 +0,0 @@
|
||||||
package commands
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/bwmarrin/discordgo"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DetailedDescription struct {
|
|
||||||
Usage string
|
|
||||||
Examples []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Command struct {
|
|
||||||
Name string
|
|
||||||
Aliases []string
|
|
||||||
Description string
|
|
||||||
DetailedDescription DetailedDescription
|
|
||||||
}
|
|
||||||
|
|
||||||
type DiscommandStruct struct {
|
|
||||||
Commands map[string]Command
|
|
||||||
Aliases map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
func new() *DiscommandStruct {
|
|
||||||
discommand := DiscommandStruct{}
|
|
||||||
discommand.Commands = make(map[string]Command)
|
|
||||||
discommand.Aliases = make(map[string]string)
|
|
||||||
discommand.loadCommands(HelpCommand)
|
|
||||||
return &discommand
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DiscommandStruct) loadCommands(command Command) {
|
|
||||||
d.Commands[command.Name] = command
|
|
||||||
d.Aliases[command.Name] = command.Name
|
|
||||||
|
|
||||||
for _, alias := range command.Aliases {
|
|
||||||
d.Aliases[alias] = command.Name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DiscommandStruct) MessageRun(command string, s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
||||||
// 극한의 하드코딩 으아악
|
|
||||||
switch command {
|
|
||||||
case "도움말":
|
|
||||||
HelpCommand.MessageRun(s, m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var Discommand *DiscommandStruct = new()
|
|
|
@ -1,17 +0,0 @@
|
||||||
package commands
|
|
||||||
|
|
||||||
import "github.com/bwmarrin/discordgo"
|
|
||||||
|
|
||||||
var HelpCommand Command = Command{
|
|
||||||
Name: "도움말",
|
|
||||||
Aliases: []string{"도움", "명령어", "help"},
|
|
||||||
Description: "기본적인 사용ㅂ법이에요.",
|
|
||||||
DetailedDescription: DetailedDescription{
|
|
||||||
Usage: "머핀아 도움말 [명령어]",
|
|
||||||
Examples: []string{"머핀아 도움말", "머핀아 도움말 배워"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Command) MessageRun(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
||||||
s.ChannelMessageSend(m.ChannelID, "asdf")
|
|
||||||
}
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module git.wh64.net/muffin/goMuffin
|
module gitlab.wh64.net/muffin/goMuffin
|
||||||
|
|
||||||
go 1.23.2
|
go 1.23.2
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@ package handler
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.wh64.net/muffin/goMuffin/commands"
|
|
||||||
"git.wh64.net/muffin/goMuffin/configs"
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"gitlab.wh64.net/muffin/goMuffin/configs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MessageCreate is handlers of messageCreate event
|
// MessageCreate is handlers of messageCreate event
|
||||||
|
@ -17,13 +16,9 @@ func MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
|
|
||||||
if strings.HasPrefix(m.Content, config.Prefix) {
|
if strings.HasPrefix(m.Content, config.Prefix) {
|
||||||
content := strings.TrimPrefix(m.Content, config.Prefix)
|
content := strings.TrimPrefix(m.Content, config.Prefix)
|
||||||
command := commands.Discommand.Aliases[content]
|
if content == "안녕" {
|
||||||
|
s.ChannelMessageSend(m.ChannelID, "안녕")
|
||||||
if command == "" {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
commands.Discommand.MessageRun(command, s, m)
|
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
4
main.go
4
main.go
|
@ -7,9 +7,9 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.wh64.net/muffin/goMuffin/configs"
|
|
||||||
"git.wh64.net/muffin/goMuffin/handler"
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"gitlab.wh64.net/muffin/goMuffin/configs"
|
||||||
|
"gitlab.wh64.net/muffin/goMuffin/handler"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue