1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-discord.git synced 2024-11-24 23:23:01 +00:00

minor bug fixes

This commit is contained in:
diamondburned 2021-01-02 20:44:30 -08:00
parent a691813b90
commit 14970d0e05
6 changed files with 12 additions and 26 deletions

View file

@ -21,7 +21,7 @@ type Completer struct {
SlashHandler cchat.Completer
}
const MaxCompletion = 15
const MaxCompletion = 50
func New(ch shared.Channel) cchat.Completer {
completer := ChannelCompleter{ch}

View file

@ -44,7 +44,7 @@ GuildSearch:
Raw: raw,
Text: text.Rich{Content: ":" + emoji.Name + ":"},
Secondary: text.Rich{Content: guild.Name},
IconURL: urlutils.Sized(emoji.EmojiURL(), 32), // small
IconURL: urlutils.Sized(emoji.EmojiURL(), 64),
Image: true,
})

View file

@ -6,6 +6,7 @@ import (
"github.com/diamondburned/cchat"
"github.com/diamondburned/cchat-discord/internal/discord/message"
"github.com/diamondburned/cchat-discord/internal/discord/state"
"github.com/diamondburned/cchat-discord/internal/urlutils"
"github.com/diamondburned/cchat/text"
)
@ -108,7 +109,7 @@ func AllUsers(s *state.Instance, word string) []cchat.CompletionEntry {
Raw: raw,
Text: text.Plain(r.User.Username + "#" + r.User.Discriminator),
Secondary: text.Plain(FormatStatus(status) + " - " + FormatRelationshipType(r.Type)),
IconURL: r.User.AvatarURL(),
IconURL: urlutils.AvatarURL(r.User.AvatarURL()),
})
distances[raw] = rank
@ -142,7 +143,7 @@ func AllUsers(s *state.Instance, word string) []cchat.CompletionEntry {
Raw: raw,
Text: text.Plain(p.User.Username + "#" + p.User.Discriminator),
Secondary: text.Plain(FormatStatus(p.Status)),
IconURL: p.User.AvatarURL(),
IconURL: urlutils.AvatarURL(p.User.AvatarURL()),
})
distances[raw] = rank
@ -222,7 +223,7 @@ func (ch ChannelCompleter) CompleteMentions(word string) []cchat.CompletionEntry
Raw: raw,
Text: text.Rich{Content: u.Username},
Secondary: text.Rich{Content: u.Username + "#" + u.Discriminator},
IconURL: u.AvatarURL(),
IconURL: urlutils.AvatarURL(u.AvatarURL()),
})
distances[raw] = rank
@ -266,7 +267,7 @@ func (ch ChannelCompleter) CompleteMentions(word string) []cchat.CompletionEntry
Raw: raw,
Text: message.RenderMemberName(mem, *g, ch.State),
Secondary: text.Plain(mem.User.Username + "#" + mem.User.Discriminator),
IconURL: mem.User.AvatarURL(),
IconURL: urlutils.AvatarURL(mem.User.AvatarURL()),
})
distances[raw] = rank

View file

@ -25,16 +25,12 @@ type messageHeader struct {
var _ cchat.MessageHeader = (*messageHeader)(nil)
func newHeader(msg discord.Message) messageHeader {
var h = messageHeader{
return messageHeader{
id: msg.ID,
time: msg.Timestamp,
channelID: msg.ChannelID,
guildID: msg.GuildID,
}
if msg.EditedTimestamp.IsValid() {
h.time = msg.EditedTimestamp
}
return h
}
func newHeaderNonce(msg discord.Message, nonce string) messageHeader {

View file

@ -2,7 +2,6 @@ package session
import (
"context"
"log"
"github.com/diamondburned/arikawa/v2/gateway"
"github.com/diamondburned/arikawa/v2/session"
@ -85,7 +84,7 @@ func (s *Session) Servers(container cchat.ServersContainer) error {
// Set the entire container again once reconnected.
s.state.AddHandler(func(*ningen.Connected) {
log.Println("[Discord] ningen.Connected received, error:", s.servers(container))
s.servers(container)
})
return s.servers(container)

View file

@ -1,10 +1,9 @@
package emoji
import (
"net/url"
"github.com/diamondburned/arikawa/v2/discord"
"github.com/diamondburned/cchat-discord/internal/segments/renderer"
"github.com/diamondburned/cchat-discord/internal/urlutils"
"github.com/diamondburned/cchat/text"
"github.com/diamondburned/cchat/utils/empty"
"github.com/diamondburned/ningen/v2/md"
@ -42,16 +41,7 @@ type Emoji struct {
var _ text.Imager = (*Emoji)(nil)
func injectSizeURL(fullURL string) string {
u, err := url.Parse(fullURL)
if err != nil {
return fullURL
}
v := u.Query()
v.Set("size", "64")
u.RawQuery = v.Encode()
return u.String()
return urlutils.Sized(fullURL, 64)
}
func EmojiFromNode(n *md.Emoji) Emoji {
@ -65,8 +55,8 @@ func EmojiFromNode(n *md.Emoji) Emoji {
func EmojiFromDiscord(e discord.Emoji, large bool) Emoji {
return Emoji{
Name: e.Name,
EmojiURL: injectSizeURL(e.EmojiURL()),
Large: large,
EmojiURL: injectSizeURL(e.EmojiURL()),
}
}