Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Improvements #157

Merged
merged 24 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8055983
matching main
kylepokorski Jan 21, 2025
4afd4d4
More Configuration + cat colors+images
kylepokorski Jan 22, 2025
e7672fc
Fix category image+color
kylepokorski Jan 22, 2025
f946895
Query+Hint changes
kylepokorski Jan 23, 2025
f79ef3b
!ac and !rc multiple nonexistent elements + no duplicate nonexistent …
kylepokorski Jan 24, 2025
390ed7f
Adding !hq/!hintquery, and !lb sort text commands
kylepokorski Jan 26, 2025
6ff0252
Adding info category and info query text commands
kylepokorski Jan 26, 2025
1bb8370
Update msgs.go
kylepokorski Jan 26, 2025
051687c
Command improvements
kylepokorski Jan 27, 2025
b40d2a8
Delete Category text command
kylepokorski Jan 27, 2025
0b1559b
Adding image and color to products
kylepokorski Jan 27, 2025
249f0fa
Adding ping command
kylepokorski Jan 30, 2025
85ef3c7
Adding elemcats command
kylepokorski Jan 31, 2025
216b636
Removing image slash command
kylepokorski Feb 2, 2025
05c60d2
Adding text commands for query and cat sort
kylepokorski Feb 6, 2025
2aebf5b
Revert "Removing image slash command"
kylepokorski Feb 7, 2025
4b2924a
Minor fixes
kylepokorski Feb 9, 2025
14f7a5f
fixing getElementID
kylepokorski Feb 9, 2025
7eb12d7
Delete __debug_bin1644976997
kylepokorski Feb 9, 2025
3d4d5d4
creating sorts.go
kylepokorski Feb 9, 2025
85e5f3c
Minor improvements
kylepokorski Feb 10, 2025
454ccf4
Update msgs.go
kylepokorski Feb 10, 2025
65da912
Final changes for #157
kylepokorski Feb 11, 2025
1be7df6
Merge branch 'main' into commandimprovements
kylepokorski Feb 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eod/base/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (b *Base) ConfigPlayChannels(c sevcord.Ctx, opts []any) {
))
b.configNewsMessage(c, "Changed Config - **Play Channels**")
}

func (b *Base) ConfigPlayChannelsHandler(c sevcord.Ctx, params string, opts []string) {
c.Acknowledge()

Expand Down
35 changes: 35 additions & 0 deletions eod/categories/infoedit.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package categories

import (
"database/sql"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -70,6 +71,40 @@ func (c *Categories) SignCmd(ctx sevcord.Ctx, opts []any) {
}).Input(sevcord.NewModalInput("New Comment", "None", sevcord.ModalInputStyleParagraph, 2400)))
}

func (c *Categories) MsgSignCmd(ctx sevcord.Ctx, cat string, mark string) {
ctx.Acknowledge()

var name string
var old string
err := c.db.QueryRow("SELECT name, comment FROM categories WHERE LOWER(name)=$1 AND guild=$2", strings.ToLower(cat), ctx.Guild()).Scan(&name, &old)
if err != nil {
if err == sql.ErrNoRows {
ctx.Respond(sevcord.NewMessage("Element **" + cat + "** doesn't exist! " + types.RedCircle))
return
} else {
c.base.Error(ctx, err)
return
}
}

// Make poll
res := c.polls.CreatePoll(ctx, &types.Poll{
Kind: types.PollKindCatComment,
Data: types.PgData{
"cat": name,
"new": mark,
"old": old,
},
})
if !res.Ok {
ctx.Respond(res.Response())
return
}

// Respond
ctx.Respond(sevcord.NewMessage(fmt.Sprintf("Suggested a note for **%s** 🖋️", name)))
}

func (c *Categories) ColorCmd(ctx sevcord.Ctx, opts []any) {
ctx.Acknowledge()

Expand Down
3 changes: 2 additions & 1 deletion eod/elements/combo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package elements
import (
"database/sql"
"fmt"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (e *Elements) Combine(c sevcord.Ctx, elemVals []string) {
dontExist := make([]string, 0)
for _, v := range elemVals {
_, exists := exist[strings.ToLower(v)]
if !exists {
if !exists && !slices.Contains(dontExist, "**"+v+"**") {
dontExist = append(dontExist, "**"+v+"**")
}
}
Expand Down
4 changes: 1 addition & 3 deletions eod/elements/hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,10 @@ func (e *Elements) HintHandler(c sevcord.Ctx, params string) {
e.base.Error(c, err)
return
}

// Create message

description := &strings.Builder{}
for _, item := range items {
// Emoji
//Emoji
if item.Cont {
description.WriteString(types.Check)
} else {
Expand Down
22 changes: 0 additions & 22 deletions eod/elements/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package elements

import (
"fmt"
"strconv"
"strings"

"github.com/Nv7-Github/Nv7Haven/eod/types"
Expand All @@ -15,27 +14,6 @@ func (e *Elements) InfoSlashCmd(c sevcord.Ctx, opts []any) {
e.Info(c, int(opts[0].(int64)))
}

func (e *Elements) InfoMsgCmd(c sevcord.Ctx, val string) {
c.Acknowledge()

var id int
if strings.HasPrefix(val, "#") {
var err error
id, err = strconv.Atoi(val[1:])
if err != nil {
c.Respond(sevcord.NewMessage("Invalid element ID! " + types.RedCircle))
return
}
} else {
err := e.db.QueryRow("SELECT id FROM elements WHERE guild=$1 AND LOWER(name)=$2", c.Guild(), strings.ToLower(val)).Scan(&id)
if err != nil {
e.base.Error(c, err, "Element **"+val+"** doesn't exist!")
return
}
}
e.Info(c, id)
}

const catInfoCount = 3

func (e *Elements) Info(c sevcord.Ctx, el int) {
Expand Down
5 changes: 5 additions & 0 deletions eod/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,9 @@ func (b *Bot) Init() {
AutoComplete(b.queries.Autocomplete)).
RequirePermissions(discordgo.PermissionManageServer))
b.s.AddButtonHandler("uncheese", b.elements.UncheeseHandler)
b.s.RegisterSlashCommand(sevcord.NewSlashCommand(
"ping",
"Check the server ping!",
b.PingCmd,
))
}
Loading