From 8d66c0498fa30a1cf7dac3e81782c1c4bbea57cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Mon, 14 Aug 2023 00:05:43 +0200 Subject: [PATCH] functions: Use slices package for sorting --- functions.go | 11 ----------- static_commands.go | 5 +++-- 2 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 functions.go diff --git a/functions.go b/functions.go deleted file mode 100644 index 8395f8e..0000000 --- a/functions.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -func sliceContains(s []string, e string) bool { - for _, v := range s { - if e == v { - return true - } - } - - return false -} diff --git a/static_commands.go b/static_commands.go index fb597a5..700c6c4 100644 --- a/static_commands.go +++ b/static_commands.go @@ -4,6 +4,7 @@ import ( "database/sql" "errors" "fmt" + "slices" "strings" "github.com/gempir/go-twitch-irc/v3" @@ -66,7 +67,7 @@ func (b *bot) handleCommands(parsed []string, msg *twitch.PrivateMessage) error resp := strings.Join(parsed[3:], " ") // check if built-in commands use this name - if sliceContains(faceitCommands(), name) { + if slices.Contains(faceitCommands(), name) { b.say(msg, "Cannot override built-in command.") return nil } @@ -90,7 +91,7 @@ func (b *bot) handleCommands(parsed []string, msg *twitch.PrivateMessage) error name := strings.TrimLeft(parsed[2], "!") // check if built-in commands use this name - if sliceContains(faceitCommands(), name) { + if slices.Contains(faceitCommands(), name) { b.say(msg, "Cannot delete built-in command.") return nil } -- 2.44.0