.v+t localizable. (only) main file left

This commit is contained in:
Kwoth 2017-02-14 22:48:53 +01:00
parent 431f328bb4
commit 0d0938f613
3 changed files with 105 additions and 15 deletions

View File

@ -65,10 +65,15 @@ namespace NadekoBot.Modules.Administration
try try
{ {
await guild.Owner.SendErrorAsync( await guild.Owner.SendErrorAsync(
"⚠️ I don't have **manage server** and/or **manage channels** permission," + GetTextStatic("vt_exit",
$" so I cannot run `voice+text` on **{guild.Name}** server.").ConfigureAwait(false); NadekoBot.Localization.GetCultureInfo(guild),
typeof(Administration).Name.ToLowerInvariant(),
Format.Bold(guild.Name))).ConfigureAwait(false);
}
catch
{
// ignored
} }
catch { }
using (var uow = DbHandler.UnitOfWork()) using (var uow = DbHandler.UnitOfWork())
{ {
uow.GuildConfigs.For(guild.Id, set => set).VoicePlusTextEnabled = false; uow.GuildConfigs.For(guild.Id, set => set).VoicePlusTextEnabled = false;
@ -105,9 +110,8 @@ namespace NadekoBot.Modules.Administration
if (afterVch != null && guild.AFKChannel?.Id != afterVch.Id) if (afterVch != null && guild.AFKChannel?.Id != afterVch.Id)
{ {
var roleName = GetRoleName(afterVch); var roleName = GetRoleName(afterVch);
IRole roleToAdd = guild.Roles.FirstOrDefault(x => x.Name == roleName); var roleToAdd = guild.Roles.FirstOrDefault(x => x.Name == roleName) ??
if (roleToAdd == null) (IRole) await guild.CreateRoleAsync(roleName, GuildPermissions.None).ConfigureAwait(false);
roleToAdd = await guild.CreateRoleAsync(roleName, GuildPermissions.None).ConfigureAwait(false);
ITextChannel textChannel = guild.TextChannels ITextChannel textChannel = guild.TextChannels
.FirstOrDefault(t => t.Name == GetChannelName(afterVch.Name).ToLowerInvariant()); .FirstOrDefault(t => t.Name == GetChannelName(afterVch.Name).ToLowerInvariant());
@ -115,7 +119,7 @@ namespace NadekoBot.Modules.Administration
{ {
var created = (await guild.CreateTextChannelAsync(GetChannelName(afterVch.Name).ToLowerInvariant()).ConfigureAwait(false)); var created = (await guild.CreateTextChannelAsync(GetChannelName(afterVch.Name).ToLowerInvariant()).ConfigureAwait(false));
try { await guild.CurrentUser.AddRolesAsync(roleToAdd).ConfigureAwait(false); } catch { } try { await guild.CurrentUser.AddRolesAsync(roleToAdd).ConfigureAwait(false); } catch {/*ignored*/}
await Task.Delay(50).ConfigureAwait(false); await Task.Delay(50).ConfigureAwait(false);
await created.AddPermissionOverwriteAsync(roleToAdd, new OverwritePermissions( await created.AddPermissionOverwriteAsync(roleToAdd, new OverwritePermissions(
readMessages: PermValue.Allow, readMessages: PermValue.Allow,
@ -162,7 +166,7 @@ namespace NadekoBot.Modules.Administration
var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false); var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false);
if (!botUser.GuildPermissions.ManageRoles || !botUser.GuildPermissions.ManageChannels) if (!botUser.GuildPermissions.ManageRoles || !botUser.GuildPermissions.ManageChannels)
{ {
await Context.Channel.SendErrorAsync("I require atleast **manage roles** and **manage channels permissions** to enable this feature. `(preffered Administration permission)`"); await ReplyErrorLocalized("vt_no_perms").ConfigureAwait(false);
return; return;
} }
@ -170,10 +174,12 @@ namespace NadekoBot.Modules.Administration
{ {
try try
{ {
await Context.Channel.SendErrorAsync("⚠️ You are enabling/disabling this feature and **I do not have ADMINISTRATOR permissions**. " + await ReplyErrorLocalized("vt_no_admin").ConfigureAwait(false);
"`This may cause some issues, and you will have to clean up text channels yourself afterwards.`"); }
catch
{
// ignored
} }
catch { }
} }
try try
{ {
@ -198,11 +204,11 @@ namespace NadekoBot.Modules.Administration
try { await role.DeleteAsync().ConfigureAwait(false); } catch { } try { await role.DeleteAsync().ConfigureAwait(false); } catch { }
await Task.Delay(500).ConfigureAwait(false); await Task.Delay(500).ConfigureAwait(false);
} }
await Context.Channel.SendConfirmAsync(" Successfuly **removed** voice + text feature.").ConfigureAwait(false); await ReplyConfirmLocalized("vt_disabled").ConfigureAwait(false);
return; return;
} }
_voicePlusTextCache.Add(guild.Id); _voicePlusTextCache.Add(guild.Id);
await Context.Channel.SendConfirmAsync("🆗 Successfuly **enabled** voice + text feature.").ConfigureAwait(false); await ReplyConfirmLocalized("vt_enabled").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
@ -222,7 +228,7 @@ namespace NadekoBot.Modules.Administration
var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false); var botUser = await guild.GetCurrentUserAsync().ConfigureAwait(false);
if (!botUser.GuildPermissions.Administrator) if (!botUser.GuildPermissions.Administrator)
{ {
await Context.Channel.SendErrorAsync("I need **Administrator permission** to do that.").ConfigureAwait(false); await ReplyErrorLocalized("need_admin").ConfigureAwait(false);
return; return;
} }
@ -249,7 +255,7 @@ namespace NadekoBot.Modules.Administration
await Task.Delay(500).ConfigureAwait(false); await Task.Delay(500).ConfigureAwait(false);
} }
await Context.Channel.SendConfirmAsync("Cleaned v+t.").ConfigureAwait(false); await ReplyConfirmLocalized("cleaned_up").ConfigureAwait(false);
} }
} }
} }

View File

@ -212,6 +212,15 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Cleaned up..
/// </summary>
public static string administration_cleaned_up {
get {
return ResourceManager.GetString("administration_cleaned_up", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Content. /// Looks up a localized string similar to Content.
/// </summary> /// </summary>
@ -636,6 +645,15 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to I need **Administration** permission to do that..
/// </summary>
public static string administration_need_admin {
get {
return ResourceManager.GetString("administration_need_admin", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to New Message. /// Looks up a localized string similar to New Message.
/// </summary> /// </summary>
@ -1286,6 +1304,51 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Disabled voice + text feature..
/// </summary>
public static string administration_vt_disabled {
get {
return ResourceManager.GetString("administration_vt_disabled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Enabled voice + text feature..
/// </summary>
public static string administration_vt_enabled {
get {
return ResourceManager.GetString("administration_vt_enabled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to I don&apos;t have **manage roles** and/or **manage channels** permission, so I cannot run `voice+text` on {0} server..
/// </summary>
public static string administration_vt_exit {
get {
return ResourceManager.GetString("administration_vt_exit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You are enabling/disabling this feature and **I do not have ADMINISTRATOR permissions**. This may cause some issues, and you will have to clean up text channels yourself afterwards..
/// </summary>
public static string administration_vt_no_admin {
get {
return ResourceManager.GetString("administration_vt_no_admin", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to I require atleast **manage roles** and **manage channels** permissions to enable this feature. (preffered Administration permission).
/// </summary>
public static string administration_vt_perms {
get {
return ResourceManager.GetString("administration_vt_perms", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to User {0} from text chat. /// Looks up a localized string similar to User {0} from text chat.
/// </summary> /// </summary>

View File

@ -350,6 +350,9 @@
<data name="administration_ch_topic_change" xml:space="preserve"> <data name="administration_ch_topic_change" xml:space="preserve">
<value>Channel Topic Changed</value> <value>Channel Topic Changed</value>
</data> </data>
<data name="administration_cleaned_up" xml:space="preserve">
<value>Cleaned up.</value>
</data>
<data name="administration_content" xml:space="preserve"> <data name="administration_content" xml:space="preserve">
<value>Content</value> <value>Content</value>
</data> </data>
@ -494,6 +497,9 @@
<data name="administration_mute_role_set" xml:space="preserve"> <data name="administration_mute_role_set" xml:space="preserve">
<value>New mute role set.</value> <value>New mute role set.</value>
</data> </data>
<data name="administration_need_admin" xml:space="preserve">
<value>I need **Administration** permission to do that.</value>
</data>
<data name="administration_new_msg" xml:space="preserve"> <data name="administration_new_msg" xml:space="preserve">
<value>New Message</value> <value>New Message</value>
</data> </data>
@ -714,6 +720,21 @@
<data name="administration_voice_chan_destroyed" xml:space="preserve"> <data name="administration_voice_chan_destroyed" xml:space="preserve">
<value>Voice Channel Destroyed</value> <value>Voice Channel Destroyed</value>
</data> </data>
<data name="administration_vt_disabled" xml:space="preserve">
<value>Disabled voice + text feature.</value>
</data>
<data name="administration_vt_enabled" xml:space="preserve">
<value>Enabled voice + text feature.</value>
</data>
<data name="administration_vt_exit" xml:space="preserve">
<value>I don't have **manage roles** and/or **manage channels** permission, so I cannot run `voice+text` on {0} server.</value>
</data>
<data name="administration_vt_no_admin" xml:space="preserve">
<value>You are enabling/disabling this feature and **I do not have ADMINISTRATOR permissions**. This may cause some issues, and you will have to clean up text channels yourself afterwards.</value>
</data>
<data name="administration_vt_perms" xml:space="preserve">
<value>I require atleast **manage roles** and **manage channels** permissions to enable this feature. (preffered Administration permission)</value>
</data>
<data name="administration_xmuted_text" xml:space="preserve"> <data name="administration_xmuted_text" xml:space="preserve">
<value>User {0} from text chat</value> <value>User {0} from text chat</value>
</data> </data>