Skip to content

Commit

Permalink
Various fixes/changes (#6)
Browse files Browse the repository at this point in the history
Merge from MikeModder: Remove useless fmt.Println from cmdZalgo, use -- instead of =-1 in YouTube pagination, fetch bot handle dynamically for about command, lowercase xkcd titles in xkcd command, and use time.Parse() to parse RFC3339/ISO8601 dates
  • Loading branch information
MikeModder authored and JoshuaDoes committed Sep 12, 2018
1 parent e14d48c commit 1aae8db
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd-clinet.go
Expand Up @@ -130,7 +130,7 @@ func commandAbout(args []string, env *CommandEnvironment) *discordgo.MessageEmbe
SetDescription(botData.BotName+" is a Discord bot written in Google's Go programming language, intended for conversation and fact-based queries.").
AddField("How can I use "+botData.BotName+" in my server?", "Simply open the Invite Link at the end of this message and follow the on-screen instructions.").
AddField("How can I help keep "+botData.BotName+" running?", "The best ways to help keep "+botData.BotName+" running are to either donate using the Donation Link or contribute to the source code using the Source Code Link, both at the end of this message.").
AddField("How can I use "+botData.BotName+"?", "There are many ways to make use of "+botData.BotName+".\n1) Type ``cli$help`` and try using some of the available commands.\n2) Ask "+botData.BotName+" a question, ex: ``@"+botData.BotName+"#1823, what time is it?`` or ``@"+botData.BotName+"#1823, what is DiscordApp?``.").
AddField("How can I use "+botData.BotName+"?", "There are many ways to make use of "+botData.BotName+".\n1) Type ``"+botData.CommandPrefix+"help`` and try using some of the available commands.\n2) Ask "+botData.BotName+" a question, ex: ``@"+botData.DiscordSession.State.User.String()+", what time is it?`` or ``@"+botData.DiscordSession.State.User.String()+", what is DiscordApp?``.").
AddField("Where can I join the "+botData.BotName+" Discord server?", "If you would like to get help and support with "+botData.BotName+" or experiment with the latest and greatest of "+botData.BotName+", use the Discord Server Invite Link at the end of this message.").
AddField("Bot Invite Link", botData.BotInviteURL).
AddField("Discord Server Invite Link", botData.BotDiscordURL).
Expand Down
2 changes: 0 additions & 2 deletions cmd-random.go
Expand Up @@ -62,7 +62,5 @@ func commandZalgo(args []string, env *CommandEnvironment) *discordgo.MessageEmbe
fmt.Fprint(writer, []byte(strings.Join(args, " ")))
zalgo := buf.String()

fmt.Println(fmt.Sprintf("%v", zalgo))

return NewGenericEmbed("Zalgo", string(zalgo))
}
8 changes: 4 additions & 4 deletions cmd-xkcd.go
Expand Up @@ -11,7 +11,7 @@ func commandXKCD(args []string, env *CommandEnvironment) *discordgo.MessageEmbed
case "latest":
comic, err := botData.BotClients.XKCD.Latest()
if err != nil {
return NewErrorEmbed("XKCD Error", "There was an error fetching the latest XKCD comic.")
return NewErrorEmbed("xkcd Error", "There was an error fetching the latest xkcd comic.")
}
return NewEmbed().
SetTitle("xkcd - #" + strconv.Itoa(comic.Number)).
Expand All @@ -21,7 +21,7 @@ func commandXKCD(args []string, env *CommandEnvironment) *discordgo.MessageEmbed
case "random":
comic, err := botData.BotClients.XKCD.Random()
if err != nil {
return NewErrorEmbed("XKCD Error", "There was an error fetching a random XKCD comic.")
return NewErrorEmbed("xkcd Error", "There was an error fetching a random xkcd comic.")
}
return NewEmbed().
SetTitle("xkcd - #" + strconv.Itoa(comic.Number)).
Expand All @@ -31,12 +31,12 @@ func commandXKCD(args []string, env *CommandEnvironment) *discordgo.MessageEmbed
default:
comicNumber, err := strconv.Atoi(args[0])
if err != nil {
return NewErrorEmbed("XKCD Error", "``"+args[0]+"`` is not a valid number.")
return NewErrorEmbed("xkcd Error", "``"+args[0]+"`` is not a valid number.")
}

comic, err := botData.BotClients.XKCD.Get(comicNumber)
if err != nil {
return NewErrorEmbed("XKCD Error", "There was an error fetching XKCD comic #"+args[0]+".")
return NewErrorEmbed("xkcd Error", "There was an error fetching xkcd comic #"+args[0]+".")
}
return NewEmbed().
SetTitle("xkcd - #" + args[0]).
Expand Down
5 changes: 3 additions & 2 deletions events.go
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strconv"
"strings"
"time"

"github.com/bwmarrin/discordgo"
)
Expand Down Expand Up @@ -353,7 +354,7 @@ func discordGuildMemberAdd(session *discordgo.Session, member *discordgo.GuildMe
if guildSettings[member.GuildID].LogSettings.LoggingEnabled && guildSettings[member.GuildID].LogSettings.LoggingEvents.GuildMemberAdd {
joinedAt := member.JoinedAt
joinedAtTimeFormatted := ""
joinedAtTime, err := joinedAt.Parse()
joinedAtTime, err := time.Parse(time.RFC3339, joinedAt)
if err != nil {
joinedAtTimeFormatted = string(joinedAt)
} else {
Expand Down Expand Up @@ -397,7 +398,7 @@ func discordGuildMemberRemove(session *discordgo.Session, member *discordgo.Guil
if guildSettings[member.GuildID].LogSettings.LoggingEnabled && guildSettings[member.GuildID].LogSettings.LoggingEvents.GuildMemberRemove {
joinedAt := member.JoinedAt
joinedAtTimeFormatted := ""
joinedAtTime, err := joinedAt.Parse()
joinedAtTime, err := time.Parse(time.RFC3339, joinedAt)
if err != nil {
joinedAtTimeFormatted = string(joinedAt)
} else {
Expand Down
6 changes: 3 additions & 3 deletions voice.go
Expand Up @@ -13,7 +13,7 @@ import (
isoduration "github.com/channelmeter/iso8601duration"
"github.com/jonas747/dca"
"github.com/rylio/ytdl"
"google.golang.org/api/youtube/v3"
youtube "google.golang.org/api/youtube/v3"
)

var encodeOptionsPresetHigh = &dca.EncodeOptions{
Expand Down Expand Up @@ -103,7 +103,7 @@ func (page *YouTubeResultNav) Prev() error {
return errors.New("Could not find any video results for the previous page")
}

page.PageNumber -= 1
page.PageNumber--
page.Results = response.Items
page.PrevPageToken = response.PrevPageToken
page.NextPageToken = response.NextPageToken
Expand All @@ -128,7 +128,7 @@ func (page *YouTubeResultNav) Next() error {
return errors.New("Could not find any video results for the next page")
}

page.PageNumber += 1
page.PageNumber--
page.Results = response.Items
page.PrevPageToken = response.PrevPageToken
page.NextPageToken = response.NextPageToken
Expand Down

1 comment on commit 1aae8db

@MikeModder
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait there's an error here I just noticed (my error): on line 131 I decrement the page count instead of incrementing it

Please sign in to comment.