From b02119c673282c809fef75def9c30fe4c5925adb Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sat, 19 Mar 2016 20:07:51 +0100 Subject: [PATCH] fixed v+t erroring when bot has no permissions, fix commandlist --- NadekoBot/Commands/VoicePlusTextCommand.cs | 16 +++++++++++++++ NadekoBot/Modules/Administration.cs | 23 +++++++++++----------- commandlist.md | 11 ++++++----- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/NadekoBot/Commands/VoicePlusTextCommand.cs b/NadekoBot/Commands/VoicePlusTextCommand.cs index 424d20e2..fc6494ad 100644 --- a/NadekoBot/Commands/VoicePlusTextCommand.cs +++ b/NadekoBot/Commands/VoicePlusTextCommand.cs @@ -22,10 +22,26 @@ namespace NadekoBot.Commands { // changing servers may cause bugs NadekoBot.Client.UserUpdated += async (sender, e) => { try { + if (e.Server == null) + return; var config = SpecificConfigurations.Default.Of(e.Server.Id); if (e.Before.VoiceChannel == e.After.VoiceChannel) return; if (!config.VoicePlusTextEnabled) return; + var serverPerms = e.Server.GetUser(NadekoBot.Client.CurrentUser.Id)?.ServerPermissions; + if (serverPerms == null) + return; + if (!serverPerms.Value.ManageChannels || !serverPerms.Value.ManageRoles) { + + try { + await e.Server.Owner.SendMessage( + "I don't have manage server and/or Manage Channels permission," + + $"so I cannot run voice+text on **{e.Server.Name}** server."); + } catch { } // meh + config.VoicePlusTextEnabled = false; + return; + } + var beforeVch = e.Before.VoiceChannel; if (beforeVch != null) { diff --git a/NadekoBot/Modules/Administration.cs b/NadekoBot/Modules/Administration.cs index ccb59abf..3da7fa67 100644 --- a/NadekoBot/Modules/Administration.cs +++ b/NadekoBot/Modules/Administration.cs @@ -2,6 +2,7 @@ using Discord.Commands; using Discord; using System; +using System.Collections.Generic; using System.Linq; using NadekoBot.Extensions; using System.Threading.Tasks; @@ -513,17 +514,17 @@ namespace NadekoBot.Modules { Channel commsChannel = null; cgb.CreateCommand(Prefix + "commsuser") - .Description("Sets a user for through-bot communication. Only works if server is set. Resets commschannel.**Owner only**.") - .Parameter("name", ParameterType.Unparsed) - .Do(async e => { - if (!NadekoBot.IsOwner(e.User.Id)) return; - commsUser = commsServer?.FindUsers(e.GetArg("name")).FirstOrDefault(); - if (commsUser != null) { - commsChannel = null; - await e.Channel.SendMessage("User for comms set."); - } else - await e.Channel.SendMessage("No server specified or user."); - }); + .Description("Sets a user for through-bot communication. Only works if server is set. Resets commschannel.**Owner only**.") + .Parameter("name", ParameterType.Unparsed) + .Do(async e => { + if (!NadekoBot.IsOwner(e.User.Id)) return; + commsUser = commsServer?.FindUsers(e.GetArg("name")).FirstOrDefault(); + if (commsUser != null) { + commsChannel = null; + await e.Channel.SendMessage("User for comms set."); + } else + await e.Channel.SendMessage("No server specified or user."); + }); cgb.CreateCommand(Prefix + "commsserver") .Description("Sets a server for through-bot communication.**Owner only**.") diff --git a/commandlist.md b/commandlist.md index 01a1c131..15929eb2 100644 --- a/commandlist.md +++ b/commandlist.md @@ -2,7 +2,7 @@ ######You can donate on paypal: `nadekodiscordbot@gmail.com` or Bitcoin `17MZz1JAqME39akMLrVT4XBPffQJ2n1EPa` #NadekoBot List Of Commands -Version: `NadekoBot v0.9.5919.5387` +Version: `NadekoBot v0.9.5922.6892` ### Administration Command and aliases | Description | Usage ----------------|--------------|------- @@ -178,7 +178,7 @@ Command and aliases | Description | Usage `>pollend` | Stops active poll on this server and prints the results in this channel. `>choose` | Chooses a thing from a list of things | >choose Get up;Sleep;Sleep more `>8ball` | Ask the 8ball a yes/no question. -`>attack` | Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'. | > strike @User +`>attack` | Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'. | >attack strike @User `>poketype` | Gets the users element type. Use this to do more damage with strike! `>rps` | Play a game of rocket paperclip scissors with nadkeo. | >rps scissors `>linux` | Prints a customizable Linux interjection @@ -217,6 +217,7 @@ Command and aliases | Description | Usage `~twitch`, `~tw` | Notifies this channel when a certain user starts streaming. | ~twitch SomeStreamer `~removestream`, `~rms` | Removes notifications of a certain streamer on this channel. | ~rms SomeGuy `~liststreams`, `~ls` | Lists all streams you are following on this server. | ~ls +`~we` | Shows weather data for a specified city and a country BOTH ARE REQUIRED. Weather api is very random if you make a mistake. `~yt` | Searches youtubes and shows the first result `~ani`, `~anime`, `~aq` | Queries anilist for an anime and shows the first result. `~mang`, `~manga`, `~mq` | Queries anilist for a manga and shows the first result. @@ -247,9 +248,9 @@ Command and aliases | Description | Usage `,createwar`, `,cw` | Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name. | ,cw 15 The Enemy Clan `,sw`, `,startwar` | Starts a war with a given number. `,listwar`, `,lw` | Shows the active war claims by a number. Shows all wars in a short way if no number is specified. | ,lw [war_number] or ,lw -`,claim`, `,call`, `,c` | Claims a certain base from a certain war. You can supply a name in the third optional argument to claim in someone else's place. | ,call [war_number] [base_number] (optional_otheruser) -`,cf`, `,claimfinish` | Finish your claim if you destroyed a base. Optional second argument finishes for someone else. | ,cf [war_number] (optional_other_name) -`,unclaim`, `,uncall`, `,uc` | Removes your claim from a certain war. Optional second argument denotes a person in whos place to unclaim | ,uc [war_number] (optional_other_name) +`,claim`, `,call`, `,c` | Claims a certain base from a certain war. You can supply a name in the third optional argument to claim in someone else's place. | ,call [war_number] [base_number] [optional_other_name] +`,cf`, `,claimfinish` | Finish your claim if you destroyed a base. Optional second argument finishes for someone else. | ,cf [war_number] [optional_other_name] +`,unclaim`, `,uncall`, `,uc` | Removes your claim from a certain war. Optional second argument denotes a person in whos place to unclaim | ,uc [war_number] [optional_other_name] `,endwar`, `,ew` | Ends the war with a given index. | ,ew [war_number] ### Trello