Skip to content

Commit

Permalink
GoFmt all go files
Browse files Browse the repository at this point in the history
  • Loading branch information
apiks committed Aug 1, 2019
1 parent 770c280 commit e3fa86c
Show file tree
Hide file tree
Showing 41 changed files with 933 additions and 941 deletions.
12 changes: 6 additions & 6 deletions commands/about.go
Expand Up @@ -16,7 +16,7 @@ func aboutCommand(s *discordgo.Session, m *discordgo.Message) {
guildBotLog := misc.GuildMap[m.GuildID].GuildConfig.BotLog.ID
misc.MapMutex.Unlock()

_, err := s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Hello, I'm %v and was made by Professor Apiks." +
_, err := s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Hello, I'm %v and was made by Professor Apiks."+
" I'm written in Go. Use `%vhelp` to list what commands are available to you", s.State.User.Username, guildPrefix))
if err != nil {
misc.CommandErrorHandler(s, m, err, guildBotLog)
Expand All @@ -26,9 +26,9 @@ func aboutCommand(s *discordgo.Session, m *discordgo.Message) {

func init() {
add(&command{
execute: aboutCommand,
trigger: "about",
desc: "Get info about me.",
category:"normal",
execute: aboutCommand,
trigger: "about",
desc: "Get info about me.",
category: "normal",
})
}
}
10 changes: 5 additions & 5 deletions commands/avatar.go
Expand Up @@ -67,9 +67,9 @@ func avatarCommand(s *discordgo.Session, m *discordgo.Message) {

func init() {
add(&command{
execute: avatarCommand,
trigger: "avatar",
desc: "Show user avatar. Add [@mention] or [userID] to specify a user.",
category:"normal",
execute: avatarCommand,
trigger: "avatar",
desc: "Show user avatar. Add [@mention] or [userID] to specify a user.",
category: "normal",
})
}
}
46 changes: 23 additions & 23 deletions commands/ban.go
Expand Up @@ -14,17 +14,17 @@ import (
func banCommand(s *discordgo.Session, m *discordgo.Message) {

var (
userID string
length string
reason string
success string
remaining string
userID string
length string
reason string
success string
remaining string

validSlice bool
validSlice bool

temp misc.BannedUsers
temp misc.BannedUsers

banTimestamp misc.Punishment
banTimestamp misc.Punishment
)
z, _ := time.Now().Zone()

Expand All @@ -36,11 +36,11 @@ func banCommand(s *discordgo.Session, m *discordgo.Message) {
commandStrings := strings.SplitN(m.Content, " ", 4)

if len(commandStrings) != 4 {
_, err := s.ChannelMessageSend(m.ChannelID, "Usage: `" + guildPrefix + "ban [@user, userID, or username#discrim] [time] [reason]` format. \n\n"+
"Time is in #w#d#h#m format, such as 2w1d12h30m for 2 weeks, 1 day, 12 hours, 30 minutes. Use 0d for permanent.\n" +
_, err := s.ChannelMessageSend(m.ChannelID, "Usage: `"+guildPrefix+"ban [@user, userID, or username#discrim] [time] [reason]` format. \n\n"+
"Time is in #w#d#h#m format, such as 2w1d12h30m for 2 weeks, 1 day, 12 hours, 30 minutes. Use 0d for permanent.\n"+
"Note: If using username#discrim you cannot have spaces in the username. It must be a single word.")
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand Down Expand Up @@ -68,11 +68,11 @@ func banCommand(s *discordgo.Session, m *discordgo.Message) {
}
}
if !validSlice {
_, err := s.ChannelMessageSend(m.ChannelID, "Error: Invalid length. \n Usage: `" + guildPrefix + "ban [@user or userID] [time] [reason]` format. \n\n"+
"Time is in #w#d#h#m format, such as 2w1d12h30m for 2 weeks, 1 day, 12 hours, 30 minutes. Use 0d for permanent.\n" +
_, err := s.ChannelMessageSend(m.ChannelID, "Error: Invalid length. \n Usage: `"+guildPrefix+"ban [@user or userID] [time] [reason]` format. \n\n"+
"Time is in #w#d#h#m format, such as 2w1d12h30m for 2 weeks, 1 day, 12 hours, 30 minutes. Use 0d for permanent.\n"+
"Note: If using username#discrim you cannot have spaces in the username. It must be a single word.")
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func banCommand(s *discordgo.Session, m *discordgo.Message) {
if err != nil {
_, err = s.ChannelMessageSend(m.ChannelID, "Error: User not found in server _and_ memberInfo. Cannot ban user until they join the server.")
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
misc.MapMutex.Unlock()
return
Expand All @@ -140,7 +140,7 @@ func banCommand(s *discordgo.Session, m *discordgo.Message) {
if err != nil {
_, err := s.ChannelMessageSend(m.ChannelID, "Error: Invalid time given.")
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
misc.MapMutex.Unlock()
return
Expand Down Expand Up @@ -237,7 +237,7 @@ func banCommand(s *discordgo.Session, m *discordgo.Message) {
// Sends embed bot-log message
err = BanEmbed(s, m, mem, reason, UnbanDate, perma, guildBotLog)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand All @@ -257,12 +257,12 @@ func BanEmbed(s *discordgo.Session, m *discordgo.Message, mem *discordgo.User, r
var (
embedMess discordgo.MessageEmbed
embedThumbnail discordgo.MessageEmbedThumbnail
embedFooter discordgo.MessageEmbedFooter
embedFooter discordgo.MessageEmbedFooter

// Embed slice and its fields
embedField []*discordgo.MessageEmbedField
embedFieldUserID discordgo.MessageEmbedField
embedFieldReason discordgo.MessageEmbedField
embedField []*discordgo.MessageEmbedField
embedFieldUserID discordgo.MessageEmbedField
embedFieldReason discordgo.MessageEmbedField
)

// Sets timestamp for unban date and footer
Expand Down Expand Up @@ -309,9 +309,9 @@ func init() {
add(&command{
execute: banCommand,
trigger: "ban",
aliases: []string{"b", "hammer"},
aliases: []string{"b", "hammer"},
desc: "Bans a user for a set period of time.",
elevated: true,
category: "punishment",
})
}
}
66 changes: 33 additions & 33 deletions commands/channellocks.go
Expand Up @@ -12,12 +12,12 @@ import (
func lockCommand(s *discordgo.Session, m *discordgo.Message) {

var (
roleExists bool
roleID string
airingID string
originalRolePerms *discordgo.PermissionOverwrite
originalAiringPerms *discordgo.PermissionOverwrite
originalEveryonePerms *discordgo.PermissionOverwrite
roleExists bool
roleID string
airingID string
originalRolePerms *discordgo.PermissionOverwrite
originalAiringPerms *discordgo.PermissionOverwrite
originalEveryonePerms *discordgo.PermissionOverwrite
)

misc.MapMutex.Lock()
Expand All @@ -27,7 +27,7 @@ func lockCommand(s *discordgo.Session, m *discordgo.Message) {
// Pulls info on the channel the message is in
cha, err := s.Channel(m.ChannelID)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand All @@ -37,7 +37,7 @@ func lockCommand(s *discordgo.Session, m *discordgo.Message) {
// Fetches info on server roles from the server and puts it in roles
roles, err := s.GuildRoles(m.GuildID)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand Down Expand Up @@ -75,29 +75,29 @@ func lockCommand(s *discordgo.Session, m *discordgo.Message) {

// Removes send permissions from everyone, channel role and airing role
if originalRolePerms != nil {
err = s.ChannelPermissionSet(m.ChannelID, roleID, "role", originalRolePerms.Allow & ^discordgo.PermissionSendMessages, originalRolePerms.Deny | discordgo.PermissionSendMessages)
err = s.ChannelPermissionSet(m.ChannelID, roleID, "role", originalRolePerms.Allow & ^discordgo.PermissionSendMessages, originalRolePerms.Deny|discordgo.PermissionSendMessages)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
return
}
}
if originalAiringPerms != nil {
err = s.ChannelPermissionSet(m.ChannelID, airingID, "role", originalAiringPerms.Allow & ^discordgo.PermissionSendMessages, originalAiringPerms.Deny | discordgo.PermissionSendMessages)
err = s.ChannelPermissionSet(m.ChannelID, airingID, "role", originalAiringPerms.Allow & ^discordgo.PermissionSendMessages, originalAiringPerms.Deny|discordgo.PermissionSendMessages)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
return
}
}
if originalEveryonePerms != nil {
err = s.ChannelPermissionSet(m.ChannelID, m.GuildID, "role", originalEveryonePerms.Allow & ^discordgo.PermissionSendMessages, originalEveryonePerms.Deny | discordgo.PermissionSendMessages)
err = s.ChannelPermissionSet(m.ChannelID, m.GuildID, "role", originalEveryonePerms.Allow & ^discordgo.PermissionSendMessages, originalEveryonePerms.Deny|discordgo.PermissionSendMessages)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand All @@ -122,7 +122,7 @@ func lockCommand(s *discordgo.Session, m *discordgo.Message) {
for _, modRole := range misc.GuildMap[m.GuildID].GuildConfig.CommandRoles {
err = s.ChannelPermissionSet(m.ChannelID, modRole.ID, "role", discordgo.PermissionAll, 0)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand All @@ -134,7 +134,7 @@ func lockCommand(s *discordgo.Session, m *discordgo.Message) {

_, err = s.ChannelMessageSend(m.ChannelID, "🔒 This channel has been locked.")
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand All @@ -143,7 +143,7 @@ func lockCommand(s *discordgo.Session, m *discordgo.Message) {

_, err = s.ChannelMessageSend(guildBotLog, "🔒 "+misc.ChMention(cha)+" was locked by "+m.Author.Username)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand All @@ -155,12 +155,12 @@ func lockCommand(s *discordgo.Session, m *discordgo.Message) {
func unlockCommand(s *discordgo.Session, m *discordgo.Message) {

var (
roleExists bool
roleID string
airingID string
originalRolePerms *discordgo.PermissionOverwrite
originalAiringPerms *discordgo.PermissionOverwrite
originalEveryonePerms *discordgo.PermissionOverwrite
roleExists bool
roleID string
airingID string
originalRolePerms *discordgo.PermissionOverwrite
originalAiringPerms *discordgo.PermissionOverwrite
originalEveryonePerms *discordgo.PermissionOverwrite
)

misc.MapMutex.Lock()
Expand Down Expand Up @@ -212,14 +212,14 @@ func unlockCommand(s *discordgo.Session, m *discordgo.Message) {

// Adds send permissions to the channel role and airing if it's a spoiler channel
if originalRolePerms != nil {
err = s.ChannelPermissionSet(m.ChannelID, roleID, "role", originalRolePerms.Allow | discordgo.PermissionSendMessages, originalRolePerms.Deny & ^discordgo.PermissionSendMessages)
err = s.ChannelPermissionSet(m.ChannelID, roleID, "role", originalRolePerms.Allow|discordgo.PermissionSendMessages, originalRolePerms.Deny & ^discordgo.PermissionSendMessages)
if err != nil {
misc.CommandErrorHandler(s, m, err, guildBotLog)
return
}
}
if originalAiringPerms != nil {
err = s.ChannelPermissionSet(m.ChannelID, airingID, "role", originalAiringPerms.Allow | discordgo.PermissionSendMessages, originalAiringPerms.Deny & ^discordgo.PermissionSendMessages)
err = s.ChannelPermissionSet(m.ChannelID, airingID, "role", originalAiringPerms.Allow|discordgo.PermissionSendMessages, originalAiringPerms.Deny & ^discordgo.PermissionSendMessages)
if err != nil {
misc.CommandErrorHandler(s, m, err, guildBotLog)
return
Expand Down Expand Up @@ -265,7 +265,7 @@ func unlockCommand(s *discordgo.Session, m *discordgo.Message) {
}
_, err = s.ChannelMessageSend(guildBotLog, "🔓 "+misc.ChMention(cha)+" was unlocked by "+m.Author.Username)
if err != nil {
_, err = s.ChannelMessageSend(guildBotLog, err.Error() + "\n" + misc.ErrorLocation(err))
_, err = s.ChannelMessageSend(guildBotLog, err.Error()+"\n"+misc.ErrorLocation(err))
if err != nil {
return
}
Expand All @@ -275,17 +275,17 @@ func unlockCommand(s *discordgo.Session, m *discordgo.Message) {

func init() {
add(&command{
execute: lockCommand,
trigger: "lock",
desc: "Locks a channel.",
execute: lockCommand,
trigger: "lock",
desc: "Locks a channel.",
elevated: true,
category: "channel",
})
add(&command{
execute: unlockCommand,
trigger: "unlock",
desc: "Unlocks a channel.",
execute: unlockCommand,
trigger: "unlock",
desc: "Unlocks a channel.",
elevated: true,
category: "channel",
})
}
}
16 changes: 8 additions & 8 deletions commands/channelvote.go
Expand Up @@ -18,14 +18,14 @@ var inChanCreation bool
func startVoteCommand(s *discordgo.Session, m *discordgo.Message) {

var (
peopleNum= 7
peopleNum = 7
descriptionSlice []string
voteChannel channel
controlNumVote= 0
controlNumUser= 0
controlNum= 0
typeFlag bool
admin bool
controlNumVote = 0
controlNumUser = 0
controlNum = 0
typeFlag bool
admin bool
)

misc.MapMutex.Lock()
Expand Down Expand Up @@ -62,7 +62,7 @@ func startVoteCommand(s *discordgo.Session, m *discordgo.Message) {
return
}

command := strings.Replace(messageLowercase, guildPrefix + "startvote ", "", -1)
command := strings.Replace(messageLowercase, guildPrefix+"startvote ", "", -1)
commandStrings = strings.Split(command, " ")

// Checks if [category] and [type] exist and assigns them if they do and removes them from slice
Expand Down Expand Up @@ -600,4 +600,4 @@ func init() {
elevated: false,
category: "channel",
})
}
}
8 changes: 4 additions & 4 deletions commands/commandhandler.go
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/bwmarrin/discordgo"

"github.com/r-anime/ZeroTsu/misc"
"github.com/r-anime/ZeroTsu/config"
"github.com/r-anime/ZeroTsu/misc"
)

var (
Expand All @@ -25,8 +25,8 @@ type command struct {
commandCount int
deleteAfter bool
elevated bool
admin bool
category string
admin bool
category string
}

func add(c *command) {
Expand Down Expand Up @@ -166,4 +166,4 @@ func HasPermissions(m *discordgo.Member, guildID string) bool {
}
}
return false
}
}

0 comments on commit e3fa86c

Please sign in to comment.