1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2025-01-03 23:10:11 +00:00

Compare commits

...

7 Commits

Author SHA1 Message Date
035dbde819
last image 2021-05-23 02:11:48 +01:00
c373d8b2d6
add final oauth tab image 2021-05-23 02:08:02 +01:00
8698c3c6a4
add oauth2 section to bot instructions 2021-05-23 02:03:55 +01:00
0edd2ba68b
add settings image for bot setup 2021-05-23 01:51:59 +01:00
b91f0b5a18
Discord: add images for bot creation instructions 2021-05-23 01:38:40 +01:00
24fa841c0d
Discord: Wait for non-nil pointer to bot data
While testing others things, I had quite a few nil pointer dereference
errors from accessing bot data right after initializing. A for loop now
waits until the first of the pointers is non-nil, which should
hopefully avoid crashes.
2021-05-23 01:09:03 +01:00
44558b8109
Discord: Remove extra newlines around links
Since links are converted into embeds, links put on their own line often
lead to extra newlines that looks pretty weird. They should now be
stripped.
2021-05-23 01:05:53 +01:00
10 changed files with 14 additions and 0 deletions

View File

@ -76,6 +76,10 @@ func (d *DiscordDaemon) run() {
d.app.err.Printf("Discord: Failed to start daemon: %v", err)
return
}
// Sometimes bot.State isn't populated quick enough
for d.bot.State == nil {
continue
}
d.username = d.bot.State.User.Username
// Choose the last guild (server), for now we don't really support multiple anyway
guild, err := d.bot.Guild(d.bot.State.Guilds[len(d.bot.State.Guilds)-1].ID)

BIN
images/discord/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
images/discord/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
images/discord/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
images/discord/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
images/discord/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

BIN
images/discord/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
images/discord/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
images/discord/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -44,6 +44,16 @@ func StripAltText(md string, links bool) (string, []*dg.MessageEmbed) {
out += md[URLStart : URLEnd+1]
}
previousURLEnd = URLEnd
// Removing links often leaves a load of extra newlines which look weird, this removes them.
if links {
next := 2
for md[URLEnd+next] == '\n' {
next++
}
if next >= 3 {
previousURLEnd += next - 2
}
}
altTextStart, URLStart, URLEnd = -1, -1, -1
continue
}