fixed v+t erroring when bot has no permissions, fix commandlist

This commit is contained in:
Master Kwoth
2016-03-19 20:07:51 +01:00
parent 8304d915d4
commit b02119c673
3 changed files with 34 additions and 16 deletions

View File

@ -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) {

View File

@ -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**.")