Skip to content

Commit

Permalink
New delete syntax & add ability to create categories
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnpn committed Aug 13, 2019
1 parent 46c7d6b commit 461d07b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
54 changes: 32 additions & 22 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ func commandRaw(session *discordgo.Session, source commandSource, cmd string, ar
}
case "new":
if nargs < 2 {
stdutil.PrintErr("new <channel/vchannel/guild> <name>", nil)
stdutil.PrintErr("new <channel/vchannel/guild/category> <name>", nil)
return
}
switch strings.ToLower(args[0]) {
Expand Down Expand Up @@ -995,34 +995,44 @@ func commandRaw(session *discordgo.Session, source commandSource, cmd string, ar
return
}
fmt.Println(tl("information.channel") + args[1] + tl("information.created.successfully") + vc.ID + ".")
case "category":
if loc.guild == nil {
stdutil.PrintErr(tl("invalid.guild"), nil)
return
}
c, err := session.GuildChannelCreate(loc.guild.ID, args[1], discordgo.ChannelTypeGuildCategory)
if err != nil {
stdutil.PrintErr(tl("failed.category.create"), err)
return
}
fmt.Println(tl("information.category") + args[1] + tl("information.created.successfully") + c.ID + ".")
default:
stdutil.PrintErr("new <channel/vchannel/guild> <name>", nil)
}
case "channeldelete":
if nargs < 1 {
stdutil.PrintErr("channeldelete <channel id>", nil)
return
}
_, err := session.ChannelDelete(args[0])
if err != nil {
stdutil.PrintErr(tl("failed.channel.delete"), err)
return
stdutil.PrintErr("new <channel/vchannel/guild/category> <name>", nil)
}
fmt.Println(tl("information.channel") + args[0] + tl("information.deleted.successfully"))
case "guilddelete":
if nargs < 1 {
stdutil.PrintErr("guilddelete <guild id>", nil)
case "delete":
if nargs < 2 {
stdutil.PrintErr("delete <guild/channel/category> <id>", nil)
return
}
_, err := session.GuildDelete(args[0])
if err != nil {
stdutil.PrintErr(tl("failed.guild.delete"), err)
return
switch strings.ToLower(args[0]) {
case "channel", "category":
_, err := session.ChannelDelete(args[1])
if err != nil {
stdutil.PrintErr(tl("failed.channel.delete"), err)
return
}
fmt.Println(tl("information.channel") + args[1] + tl("information.deleted.successfully"))
case "guild":
_, err := session.GuildDelete(args[1])
if err != nil {
stdutil.PrintErr(tl("failed.guild.delete"), err)
return
}
fmt.Println(tl("information.guild") + args[1] + tl("information.deleted.successfully"))
}
fmt.Println(tl("information.channel") + args[0] + tl("information.deleted.successfully"))
case "move":
if nargs < 2 {
stdutil.PrintErr("move <user ID> <vchannel ID>", nil)
stdutil.PrintErr("move <user id> <vchannel id>", nil)
return
}
if loc.guild == nil {
Expand Down
5 changes: 5 additions & 0 deletions completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ func setCompleter(rl *readline.Instance) {
readline.PcItem("vchannel"),
readline.PcItem("guild"),
),
readline.PcItem("delete",
readline.PcItem("guild"),
readline.PcItem("channel"),
readline.PcItem("category"),
),
)
}
func bookmarkTab(line string) []string {
Expand Down
6 changes: 3 additions & 3 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ func printHelp(search string) {
help = append(help, "output [yes/no]\tToggle showing 'console.' outputs directly in Discord.")
help = append(help, "back\tJump to previous guild and/or channel.")
help = append(help, "")
help = append(help, "new <channel/vchannel/guild> <name>\tCreate a new guild or channel")
help = append(help, "new <channel/vchannel/guild/category> <name>\tCreate a new guild or channel")
help = append(help, "bans\tList all bans")
help = append(help, "ban <user id> <optional reason>\tBan user")
help = append(help, "unban <user id>\tUnban user")
help = append(help, "kick <user id> <optional reason>\tKick user")
help = append(help, "leave\tLeave selected guild!")
help = append(help, "ownership <id>\tTransfer ownership.")
help = append(help, "")
help = append(help, "channeldelete <channel id>\tDelete a channel.")
help = append(help, "guilddelete <guild id>\tDelete a guild.")
// Deleting a category also works when selecting channel, but this is less confusing, I hope.
help = append(help, "delete <guild/channel/category> <id>\tDelete a channel, guild or category.")
help = append(help, "")
help = append(help, "play <dca audio file>\tPlays a song in the selected voice channel")
help = append(help, "stop\tStops playing any song.")
Expand Down
5 changes: 4 additions & 1 deletion languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ failed.channel=Could not query channel
failed.guild=Could not query guild
failed.guild.edit=Could not edit guild
failed.channel.create=Could not create channel
failed.category.create=Could not create category
failed.channel.delete=Could not delete channel
failed.guild.create=Could not create guild
failed.guild.delete=Could not delete guild
failed.settings=Could not query user settings
failed.timestamp=Couldn't parse timestamp
failed.channel.create=Could not create channel
failed.msg.query=Could not get message
failed.msg.send=Could not send message
failed.msg.edit=Couldn't edit message
Expand Down Expand Up @@ -198,6 +198,7 @@ information.confirmation=Are you really sure you want to do this?
information.aborted=Aborted.
information.guild=Guild "
information.channel=Channel "
information.category=Category "
information.created.successfully=" was created successfully with ID
information.deleted.successfully=" was deleted successfully.
information.revoked.successfully=Revoked
Expand Down Expand Up @@ -278,6 +279,7 @@ failed.guild=Kunde inte fråga efter server
failed.guild.edit=Kunde inte skapa servern
failed.timestamp=Kunde inte tolka tidsstämplar
failed.channel.create=Kunde inte skapa kanal
failed.category.create=Kunde inte skapa kategori
failed.channel.delete=Kunde inte ta bort kanal
failed.guild.create=Kunde inte skapa server
failed.guild.delete=Kunde inte ta bort server
Expand Down Expand Up @@ -341,6 +343,7 @@ information.confirmation=Vill du verkligen göra detta?
information.aborted=Avbrutet.
information.guild=Servern "
information.channel=Kanalen "
information.category=Kategorin "
information.created.successfully=" skapades med ID
information.deleted.successfully=" togs bort.
information.revoked.successfully=Återkallade
Expand Down

0 comments on commit 461d07b

Please sign in to comment.