self assigned role commands can now be localized :3
This commit is contained in:
parent
6ab8f26cd7
commit
fd81b2de26
@ -44,25 +44,30 @@ namespace NadekoBot.Modules.Administration
|
||||
IEnumerable<SelfAssignedRole> roles;
|
||||
|
||||
string msg;
|
||||
var error = false;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
roles = uow.SelfAssignedRoles.GetFromGuild(Context.Guild.Id);
|
||||
if (roles.Any(s => s.RoleId == role.Id && s.GuildId == role.Guild.Id))
|
||||
{
|
||||
await Context.Channel.SendMessageAsync($"💢 Role **{role.Name}** is already in the list.").ConfigureAwait(false);
|
||||
return;
|
||||
msg = GetText("role_in_list", Format.Bold(role.Name));
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
uow.SelfAssignedRoles.Add(new SelfAssignedRole {
|
||||
uow.SelfAssignedRoles.Add(new SelfAssignedRole
|
||||
{
|
||||
RoleId = role.Id,
|
||||
GuildId = role.Guild.Id
|
||||
});
|
||||
await uow.CompleteAsync();
|
||||
msg = $"🆗 Role **{role.Name}** added to the list.";
|
||||
msg = GetText("role_added", Format.Bold(role.Name));
|
||||
}
|
||||
}
|
||||
await Context.Channel.SendConfirmAsync(msg.ToString()).ConfigureAwait(false);
|
||||
if (error)
|
||||
await Context.Channel.SendErrorAsync(msg).ConfigureAwait(false);
|
||||
else
|
||||
await Context.Channel.SendConfirmAsync(msg).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -70,8 +75,6 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequireUserPermission(GuildPermission.ManageRoles)]
|
||||
public async Task Rsar([Remainder] IRole role)
|
||||
{
|
||||
//var channel = (ITextChannel)Context.Channel;
|
||||
|
||||
bool success;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
@ -80,18 +83,16 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync("❎ That role is not self-assignable.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_not").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await Context.Channel.SendConfirmAsync($"🗑 **{role.Name}** has been removed from the list of self-assignable roles.").ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("self_assign_rem", Format.Bold(role.Name)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Lsar()
|
||||
{
|
||||
//var channel = (ITextChannel)Context.Channel;
|
||||
|
||||
var toRemove = new ConcurrentHashSet<SelfAssignedRole>();
|
||||
var removeMsg = new StringBuilder();
|
||||
var msg = new StringBuilder();
|
||||
@ -116,11 +117,11 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
foreach (var role in toRemove)
|
||||
{
|
||||
removeMsg.AppendLine($"`{role.RoleId} not found. Cleaned up.`");
|
||||
removeMsg.AppendLine(GetText("role_clean", role.RoleId));
|
||||
}
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
await Context.Channel.SendConfirmAsync($"ℹ️ There are `{roleCnt}` self assignable roles:", msg.ToString() + "\n\n" + removeMsg.ToString()).ConfigureAwait(false);
|
||||
await Context.Channel.SendConfirmAsync(GetText("self_assign_list", roleCnt), msg + "\n\n" + removeMsg).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
@ -128,8 +129,6 @@ namespace NadekoBot.Modules.Administration
|
||||
[RequireUserPermission(GuildPermission.ManageRoles)]
|
||||
public async Task Tesar()
|
||||
{
|
||||
//var channel = (ITextChannel)Context.Channel;
|
||||
|
||||
bool areExclusive;
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
@ -138,15 +137,16 @@ namespace NadekoBot.Modules.Administration
|
||||
areExclusive = config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles;
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
string exl = areExclusive ? "**exclusive**." : "**not exclusive**.";
|
||||
await Context.Channel.SendConfirmAsync("ℹ️ Self assigned roles are now " + exl);
|
||||
if(areExclusive)
|
||||
await ReplyConfirmLocalized("self_assign_excl").ConfigureAwait(false);
|
||||
else
|
||||
await ReplyConfirmLocalized("self_assign_no_excl").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Iam([Remainder] IRole role)
|
||||
{
|
||||
//var channel = (ITextChannel)Context.Channel;
|
||||
var guildUser = (IGuildUser)Context.User;
|
||||
|
||||
GuildConfig conf;
|
||||
@ -156,25 +156,24 @@ namespace NadekoBot.Modules.Administration
|
||||
conf = uow.GuildConfigs.For(Context.Guild.Id, set => set);
|
||||
roles = uow.SelfAssignedRoles.GetFromGuild(Context.Guild.Id);
|
||||
}
|
||||
SelfAssignedRole roleModel;
|
||||
if ((roleModel = roles.FirstOrDefault(r=>r.RoleId == role.Id)) == null)
|
||||
if (roles.FirstOrDefault(r=>r.RoleId == role.Id) == null)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync("That role is not self-assignable.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_not").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (guildUser.RoleIds.Contains(role.Id))
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"You already have **{role.Name}** role.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_already", Format.Bold(role.Name)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (conf.ExclusiveSelfAssignedRoles)
|
||||
{
|
||||
var sameRoleId = guildUser.RoleIds.Where(r => roles.Select(sar => sar.RoleId).Contains(r)).FirstOrDefault();
|
||||
var sameRoleId = guildUser.RoleIds.FirstOrDefault(r => roles.Select(sar => sar.RoleId).Contains(r));
|
||||
var sameRole = Context.Guild.GetRole(sameRoleId);
|
||||
if (sameRoleId != default(ulong))
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"You already have **{sameRole?.Name}** `exclusive self-assigned` role.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_already_excl", Format.Bold(sameRole?.Name)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -184,11 +183,11 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"⚠️ I am unable to add that role to you. `I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_perms").ConfigureAwait(false);
|
||||
Console.WriteLine(ex);
|
||||
return;
|
||||
}
|
||||
var msg = await Context.Channel.SendConfirmAsync($"🆗 You now have **{role.Name}** role.").ConfigureAwait(false);
|
||||
var msg = await ReplyConfirmLocalized("self_assign_success",Format.Bold(role.Name)).ConfigureAwait(false);
|
||||
|
||||
if (conf.AutoDeleteSelfAssignedRoleMessages)
|
||||
{
|
||||
@ -210,15 +209,14 @@ namespace NadekoBot.Modules.Administration
|
||||
autoDeleteSelfAssignedRoleMessages = uow.GuildConfigs.For(Context.Guild.Id, set => set).AutoDeleteSelfAssignedRoleMessages;
|
||||
roles = uow.SelfAssignedRoles.GetFromGuild(Context.Guild.Id);
|
||||
}
|
||||
SelfAssignedRole roleModel;
|
||||
if ((roleModel = roles.FirstOrDefault(r => r.RoleId == role.Id)) == null)
|
||||
if (roles.FirstOrDefault(r => r.RoleId == role.Id) == null)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync("💢 That role is not self-assignable.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_not").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (!guildUser.RoleIds.Contains(role.Id))
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"❎ You don't have **{role.Name}** role.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_not_have",Format.Bold(role.Name)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
try
|
||||
@ -227,10 +225,10 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await Context.Channel.SendErrorAsync($"⚠️ I am unable to add that role to you. `I can't remove roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("self_assign_perms").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var msg = await Context.Channel.SendConfirmAsync($"🆗 You no longer have **{role.Name}** role.").ConfigureAwait(false);
|
||||
var msg = await ReplyConfirmLocalized("self_assign_remove", Format.Bold(role.Name)).ConfigureAwait(false);
|
||||
|
||||
if (autoDeleteSelfAssignedRoleMessages)
|
||||
{
|
||||
|
126
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
126
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -59,6 +59,24 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You already have {0} role..
|
||||
/// </summary>
|
||||
public static string administartion_self_assign_already {
|
||||
get {
|
||||
return ResourceManager.GetString("administartion_self_assign_already", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You no longer have {0} role..
|
||||
/// </summary>
|
||||
public static string administartion_self_assign_remove {
|
||||
get {
|
||||
return ResourceManager.GetString("administartion_self_assign_remove", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to **Auto assign role** on user join is now **disabled**..
|
||||
/// </summary>
|
||||
@ -537,6 +555,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Role {0} as been added to the list..
|
||||
/// </summary>
|
||||
public static string administration_role_added {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_role_added", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} not found.Cleaned up..
|
||||
/// </summary>
|
||||
public static string administration_role_clean {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_role_clean", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Role {0} is already in the list..
|
||||
/// </summary>
|
||||
public static string administration_role_in_list {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_role_in_list", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Added..
|
||||
/// </summary>
|
||||
@ -583,6 +628,87 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You already have {0} exclusive self-assigned role..
|
||||
/// </summary>
|
||||
public static string administration_self_assign_already_excl {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_already_excl", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Self assigned roles are now exclusive!.
|
||||
/// </summary>
|
||||
public static string administration_self_assign_excl {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_excl", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to There are {0} self assignable roles.
|
||||
/// </summary>
|
||||
public static string administration_self_assign_list {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_list", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Self assigned roles are now not exclusive!.
|
||||
/// </summary>
|
||||
public static string administration_self_assign_no_excl {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_no_excl", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to That role is not self-assignable..
|
||||
/// </summary>
|
||||
public static string administration_self_assign_not {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_not", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You don't have {0} role..
|
||||
/// </summary>
|
||||
public static string administration_self_assign_not_have {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_not_have", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to I am unable to add that role to you. `I can't add roles to owners or other roles higher than my role in the role hierarchy.`.
|
||||
/// </summary>
|
||||
public static string administration_self_assign_perms {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_perms", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} has been removed from the list of self-assignable roles..
|
||||
/// </summary>
|
||||
public static string administration_self_assign_rem {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_rem", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You now have {0} role..
|
||||
/// </summary>
|
||||
public static string administration_self_assign_sucess {
|
||||
get {
|
||||
return ResourceManager.GetString("administration_self_assign_sucess", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Users can't send more than {0} messages every {1} seconds..
|
||||
/// </summary>
|
||||
|
@ -298,6 +298,12 @@
|
||||
<data name="pokemon_you_fainted" xml:space="preserve">
|
||||
<value>You fainted, so you are not able to move!</value>
|
||||
</data>
|
||||
<data name="administartion_self_assign_already" xml:space="preserve">
|
||||
<value>You already have {0} role.</value>
|
||||
</data>
|
||||
<data name="administartion_self_assign_remove" xml:space="preserve">
|
||||
<value>You no longer have {0} role.</value>
|
||||
</data>
|
||||
<data name="administration_aar_disabled" xml:space="preserve">
|
||||
<value>**Auto assign role** on user join is now **disabled**.</value>
|
||||
</data>
|
||||
@ -461,6 +467,15 @@
|
||||
<data name="administration_reprm" xml:space="preserve">
|
||||
<value>Removed the playing message: {0}</value>
|
||||
</data>
|
||||
<data name="administration_role_added" xml:space="preserve">
|
||||
<value>Role {0} is added to the list.</value>
|
||||
</data>
|
||||
<data name="administration_role_clean" xml:space="preserve">
|
||||
<value>{0} not found.Cleaned up.</value>
|
||||
</data>
|
||||
<data name="administration_role_in_list" xml:space="preserve">
|
||||
<value>Role {0} is already in the list.</value>
|
||||
</data>
|
||||
<data name="administration_ropl_added" xml:space="preserve">
|
||||
<value>Added.</value>
|
||||
</data>
|
||||
@ -477,6 +492,34 @@
|
||||
<data name="administration_ropl_not_set" xml:space="preserve">
|
||||
<value>No rotating playing statuses set.</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_already_excl" xml:space="preserve">
|
||||
<value>You already have {0} exclusive self-assigned role.</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_excl" xml:space="preserve">
|
||||
<value>Self assigned roles are now exclusive!</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_list" xml:space="preserve">
|
||||
<value>There are {0} self assignable roles:
|
||||
{1}</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_not" xml:space="preserve">
|
||||
<value>That role is not self-assignable.</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_not_have" xml:space="preserve">
|
||||
<value>You don't have {0} role.</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_no_excl" xml:space="preserve">
|
||||
<value>Self assigned roles are now not exclusive!</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_perms" xml:space="preserve">
|
||||
<value>I am unable to add that role to you. `I can't add roles to owners or other roles higher than my role in the role hierarchy.`</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_rem" xml:space="preserve">
|
||||
<value>{0} has been removed from the list of self-assignable roles.</value>
|
||||
</data>
|
||||
<data name="administration_self_assign_sucsess" xml:space="preserve">
|
||||
<value>You now have {0} role.</value>
|
||||
</data>
|
||||
<data name="administration_slowmode_desc" xml:space="preserve">
|
||||
<value>Users can't send more than {0} messages every {1} seconds.</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user