Skip to content

Commit

Permalink
Add way to bypass gtable for bans
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnpn committed Aug 16, 2019
1 parent 2a108de commit 3c2948f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
43 changes: 36 additions & 7 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,22 +522,51 @@ func commandRaw(session *discordgo.Session, source commandSource, cmd string, ar
stdutil.PrintErr(tl("invalid.guild"), nil)
return
}
arg := ""
if nargs > 0 {
arg = strings.ToLower(args[0])
if arg != "text" {
stdutil.PrintErr("bans [text]", nil)
return
}
}

bans, err := session.GuildBans(loc.guild.ID)
if err != nil {
stdutil.PrintErr(tl("failed.ban.list"), err)
return
}

table := gtable.NewStringTable()
table.AddStrings("User ID", "Username", "Reason")
if nargs < 1 {
lengthNotify := false
table := gtable.NewStringTable()
table.AddStrings("User ID", "Username", "Reason")

for _, ban := range bans {
table.AddRow()
table.AddStrings(ban.User.ID, ban.User.Username, ban.Reason)
}
for _, ban := range bans {
reason := ban.Reason
if len(reason) > 100 {
reason = reason[0:100] + "..."
lengthNotify = true
}
table.AddRow()
table.AddStrings(ban.User.ID, ban.User.Username, reason)
}

writeln(w, table.String())
writeln(w, table.String())
if lengthNotify {
fmt.Println(tl("information.length") + " \"bans text\".")
}
} else if arg == "text" { // only reason that this exists is because gtable can break if the reason is too long
for _, ban := range bans {
reason := ""
if ban.Reason != "" {
reason = "): " + ban.Reason
} else {
reason = ")"
}
writeln(w, ban.User.Username + "#" + ban.User.Discriminator + " (" + ban.User.ID + reason + "\n")
}
}
case "nickall":
if loc.guild == nil {
stdutil.PrintErr(tl("invalid.guild"), nil)
Expand Down
2 changes: 2 additions & 0 deletions languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ information.give.ownership=This will give server ownership to
information.guild=Guild
information.channel=Channel
information.irreversible=This action is irreversible!
information.length=Some text was cut short. To see the full text, run
information.moved=Moved the user.
information.revoked.successfully=Revoked
information.wait=Wait a second!
Expand Down Expand Up @@ -353,6 +354,7 @@ information.give.ownership=Detta kommer att ge server-ägarskap till
information.guild=Servern
information.channel=Kanalen
information.irreversible=Denna åtgärd kan inte ångras!
information.length=Viss text var klippt. För att se hela texten, kör
information.moved=Flyttade användaren.
information.revoked.successfully=Återkallade
information.wait=Vänta en sekund!
Expand Down

0 comments on commit 3c2948f

Please sign in to comment.