Fixed some v+t edge cases, ref #252

This commit is contained in:
Master Kwoth 2016-05-03 06:28:55 +02:00
parent 081cb44dac
commit 374d302a41

View File

@ -1,16 +1,18 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Classes; using NadekoBot.Classes;
using NadekoBot.Extensions;
using NadekoBot.Modules.Permissions.Classes; using NadekoBot.Modules.Permissions.Classes;
using System; using System;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using ChPermOverride = Discord.ChannelPermissionOverrides; using ChPermOverride = Discord.ChannelPermissionOverrides;
namespace NadekoBot.Modules.Administration.Commands namespace NadekoBot.Modules.Administration.Commands
{ {
internal class VoicePlusTextCommand : DiscordCommand internal class VoicePlusTextCommand : DiscordCommand
{ {
Regex channelNameRegex = new Regex(@"[^a-zA-Z0-9 -]", RegexOptions.Compiled);
public VoicePlusTextCommand(DiscordModule module) : base(module) public VoicePlusTextCommand(DiscordModule module) : base(module)
{ {
// changing servers may cause bugs // changing servers may cause bugs
@ -79,7 +81,7 @@ namespace NadekoBot.Modules.Administration.Commands
} }
private string GetChannelName(string voiceName) => private string GetChannelName(string voiceName) =>
voiceName.Replace(" ", "-").Trim() + "-voice"; channelNameRegex.Replace(voiceName, "").Trim().Replace(" ", "-").TrimTo(90, true) + "-voice";
internal override void Init(CommandGroupBuilder cgb) internal override void Init(CommandGroupBuilder cgb)
{ {