fix: Renaming mutex name

This commit is contained in:
Siwoo Jeon 2025-04-05 17:39:35 +09:00
parent 9b32aaf581
commit a35ba84efc
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA

View file

@ -63,8 +63,8 @@ const (
Generals Category = "일반"
)
var mutex1 *sync.Mutex = &sync.Mutex{}
var mutex2 *sync.Mutex = &sync.Mutex{}
var commandMutex *sync.Mutex = &sync.Mutex{}
var componentMutex *sync.Mutex = &sync.Mutex{}
func new() *DiscommandStruct {
discommand := DiscommandStruct{
@ -76,40 +76,36 @@ func new() *DiscommandStruct {
}
func (d *DiscommandStruct) LoadCommand(c *Command) {
mutex1.Lock()
commandMutex.Lock()
d.Commands[c.Name] = c
d.Aliases[c.Name] = c.Name
for _, alias := range c.Aliases {
d.Aliases[alias] = c.Name
}
mutex1.Unlock()
commandMutex.Unlock()
}
func (d *DiscommandStruct) LoadComponent(c *Component) {
mutex2.Lock()
componentMutex.Lock()
d.Components = append(d.Components, c)
mutex2.Unlock()
componentMutex.Unlock()
}
func (d *DiscommandStruct) MessageRun(name string, s *discordgo.Session, m *discordgo.MessageCreate, args []string) {
command := d.Commands[name]
if command == nil {
return
if command, ok := d.Commands[name]; ok {
command.MessageRun(&MsgContext{s, m, args, command})
}
command.MessageRun(&MsgContext{s, m, args, command})
}
func (d *DiscommandStruct) ChatInputRun(name string, s *discordgo.Session, i *discordgo.InteractionCreate) {
command := d.Commands[name]
if command == nil {
return
if command, ok := d.Commands[name]; ok {
command.ChatInputRun(&ChatInputContext{s, &utils.InteractionCreate{
InteractionCreate: i,
Session: s,
Options: utils.GetInteractionOptions(i),
}, command})
}
command.ChatInputRun(&ChatInputContext{s, &utils.InteractionCreate{
InteractionCreate: i,
Session: s,
Options: utils.GetInteractionOptions(i),
}, command})
}
func (d *DiscommandStruct) ComponentRun(s *discordgo.Session, i *discordgo.InteractionCreate) {