Skip to content
Snippets Groups Projects
Commit 4dc38d72 authored by Ophestra's avatar Ophestra
Browse files

extra check to reduce unnecessary error outputs

parent f2501bd2
Branches
Tags v1.0.13
No related merge requests found
......@@ -143,7 +143,7 @@ func (context *Context) GetMember(query string) *discordgo.Member {
_, err := strconv.Atoi(query)
if strings.HasPrefix(query, "<@") && strings.HasSuffix(query, ">") || err == nil {
// Strip off the mention thingy
userID := numericalRegex.ReplaceAllString(query, "")
userID := strings.TrimSuffix(strings.TrimPrefix(strings.TrimPrefix(query, "<@"), "!"), ">")
// Length of a real snowflake after stripping off stuff
if len(userID) == 18 {
for _, member := range context.Guild.Members {
......
......@@ -32,6 +32,11 @@ func GetGuild(session *discordgo.Session, id string) *discordgo.Guild {
func GetChannel(session *discordgo.Session, id string) *discordgo.Channel {
var err error
var channel *discordgo.Channel
if id == "" {
return nil
}
channel, err = session.State.Channel(id)
if err != nil {
// Attempt direct API fetching
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment