You can now add friends that aren't in your cache by using username#discriminator
MODIFY
commands/commandimpls/friends.go
commands/commandimpls/friends.go
@@ -3,6 +3,7 @@ package commandimpls
import (
"fmt"
"io"
+ "strconv"
"strings"
"unicode"
@@ -189,14 +190,14 @@ func (f *Friends) Execute(writer io.Writer, parameters []string) {
//successful, we send a friendsrequest. Otherwise we check if the input
//might have been a user idea, lookup the user and do a request.
input := parameters[1]
- users, err := f.session.State.Users()
- var matches []*discordgo.User
+ users, err := f.session.State.Users()
if err != nil {
fmt.Fprintf(writer, "An error occured during commandexecution (%s).\n", err.Error())
return
}
+ var matches []*discordgo.User
for _, user := range users {
if user.ID == input || user.Username == input || user.String() == input {
matches = append(matches, user)
@@ -204,6 +205,21 @@ func (f *Friends) Execute(writer io.Writer, parameters []string) {
}
if len(matches) == 0 {
+ //Send friendsrequest via username and discriminator if possible
+ parts := strings.Split(input, "#")
+ if len(parts) == 2 {
+ discriminator, _ := strconv.ParseInt(parts[1], 10, 32)
+ requestError := f.session.RelationshipFriendRequestSendByNameAndDiscriminator(parts[0], int(discriminator))
+ if requestError != nil {
+ fmt.Fprintf(writer, "Error sending friendsrequest to '%s'.\n\t%s\n", input, requestError.Error())
+ return
+ }
+
+ fmt.Fprintf(writer, "A friends-reuest has been sent to '%s'.\n", input)
+ return
+ }
+
+ //If no match was found, try sending a friendsrequest if the input is a snowflake.
for _, char := range input {
if !unicode.IsNumber(char) {
fmt.Fprintf(writer, "No matches for '%s' found. Please ask that person to add you or find out the UserID.\n", input)

MODIFY
go.mod
go.mod
@@ -4,7 +4,7 @@ go 1.12
require (
github.com/Bios-Marcel/discordemojimap v0.0.0-20190404160132-506fd0e8d912
- github.com/Bios-Marcel/discordgo v0.20.4-0.20191007163810-41c4e4a91fd6
+ github.com/Bios-Marcel/discordgo v0.20.4-0.20191012193840-26cddf403c14
github.com/Bios-Marcel/goclipimg v0.0.0-20190417192721-b58a8831f27d
github.com/Bios-Marcel/shortnotforlong v1.0.0
github.com/Bios-Marcel/tview v0.0.0-20191011210517-9ff18389d0f6

MODIFY
go.sum
go.sum
@@ -2,6 +2,8 @@ github.com/Bios-Marcel/discordemojimap v0.0.0-20190404160132-506fd0e8d912 h1:Qxa
github.com/Bios-Marcel/discordemojimap v0.0.0-20190404160132-506fd0e8d912/go.mod h1:D1W9gRQXP1UESEobmNIng2i+E8UvdDF4NJ9EOXn9Ano=
github.com/Bios-Marcel/discordgo v0.20.4-0.20191007163810-41c4e4a91fd6 h1:SKG4DGHPz6ZIWfdnnHB/bto0SyypPhV6OAR8vrVmGeQ=
github.com/Bios-Marcel/discordgo v0.20.4-0.20191007163810-41c4e4a91fd6/go.mod h1:bLnfQU0j/SejmPozgW5GepmKvd8CrbMIml2I0IZENVE=
+github.com/Bios-Marcel/discordgo v0.20.4-0.20191012193840-26cddf403c14 h1:rMm2kL+lOb4eYdDexAsFV8dlEX+0V/Jkr05SZQpZ83E=
+github.com/Bios-Marcel/discordgo v0.20.4-0.20191012193840-26cddf403c14/go.mod h1:bLnfQU0j/SejmPozgW5GepmKvd8CrbMIml2I0IZENVE=
github.com/Bios-Marcel/goclipimg v0.0.0-20190417192721-b58a8831f27d h1:vfrX8l3fHuaP7gRgEc7mX/lHVTlfQcQeaIdSPmT6Ej0=
github.com/Bios-Marcel/goclipimg v0.0.0-20190417192721-b58a8831f27d/go.mod h1:u7z9t086HoIbA/uuoA2KcRDhKS47DRYCDZ39aegTR4c=
github.com/Bios-Marcel/shortnotforlong v1.0.0 h1:K4JJ5U3+D8LXoAiH0QbfMujWuqKo+NAEZKuQ2RHPqqE=

You can now add friends that aren't in your cache by using username#discriminator