I don't know if I fixed the merge conflict or not 👀

This commit is contained in:
Jordan Fearnley 2016-10-22 09:17:36 +01:00
commit 7c78ee1b4e
5 changed files with 172 additions and 40 deletions

View File

@ -301,6 +301,16 @@ namespace NadekoBot.Modules.Administration
{
msg = "No reason provided.";
}
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r=>r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max())
{
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
return;
}
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Max().Position >= ((IGuildUser)umsg.Author).Roles.Max().Position)
{
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
return;
}
try
{
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
@ -330,6 +340,11 @@ namespace NadekoBot.Modules.Administration
{
msg = "No reason provided.";
}
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Max().Position >= ((IGuildUser)umsg.Author).Roles.Max().Position)
{
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
return;
}
try
{
await user.SendMessageAsync($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
@ -363,6 +378,12 @@ namespace NadekoBot.Modules.Administration
await channel.SendMessageAsync("User not found.").ConfigureAwait(false);
return;
}
if (umsg.Author.Id != user.Guild.OwnerId && user.Roles.Select(r => r.Position).Max() >= ((IGuildUser)umsg.Author).Roles.Select(r => r.Position).Max())
{
await channel.SendMessageAsync("You can't use this command on users with a role higher or equal to yours in the role hierarchy.");
return;
}
if (!string.IsNullOrWhiteSpace(msg))
{
try
@ -412,6 +433,7 @@ namespace NadekoBot.Modules.Administration
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.ManageRoles)]
[RequirePermission(GuildPermission.MuteMembers)]
public async Task Mute(IUserMessage umsg, IGuildUser user)
{
@ -421,7 +443,7 @@ namespace NadekoBot.Modules.Administration
{
await user.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
await user.AddRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"**{user}** was text and voice muted successfully.").ConfigureAwait(false);
await channel.SendMessageAsync($"**{user}** was muted from text and voice chat successfully.").ConfigureAwait(false);
}
catch
{
@ -431,15 +453,53 @@ namespace NadekoBot.Modules.Administration
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.ManageRoles)]
[RequirePermission(GuildPermission.MuteMembers)]
public async Task TextMute(IUserMessage umsg, IGuildUser user)
public async Task Unmute(IUserMessage umsg, IGuildUser user)
{
var channel = (ITextChannel)umsg.Channel;
try
{
await user.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false);
await user.RemoveRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"**{user}** was unmuted from text and voice chat successfully.").ConfigureAwait(false);
}
catch
{
await channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false);
}
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.ManageRoles)]
public async Task ChatMute(IUserMessage umsg, IGuildUser user)
{
var channel = (ITextChannel)umsg.Channel;
try
{
await user.AddRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"**{user}** was text muted successfully.").ConfigureAwait(false);
await channel.SendMessageAsync($"**{user}** was muted from chatting successfully.").ConfigureAwait(false);
}
catch
{
await channel.SendMessageAsync("I most likely don't have the permission necessary for that.").ConfigureAwait(false);
}
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequirePermission(GuildPermission.ManageRoles)]
public async Task ChatUnmute(IUserMessage umsg, IGuildUser user)
{
var channel = (ITextChannel)umsg.Channel;
try
{
await user.RemoveRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
await channel.SendMessageAsync($"**{user}** was unmuted from chatting successfully.").ConfigureAwait(false);
}
catch
{
@ -474,7 +534,7 @@ namespace NadekoBot.Modules.Administration
try
{
await user.ModifyAsync(usr => usr.Mute = false).ConfigureAwait(false);
await channel.SendMessageAsync("Unmute successful").ConfigureAwait(false);
await channel.SendMessageAsync($"**{user}** was voice unmuted successfully.").ConfigureAwait(false);
}
catch
{

View File

@ -14,7 +14,7 @@ namespace NadekoBot.Modules.CustomReactions
{
public static Dictionary<string, Func<IUserMessage, string, string>> responsePlaceholders = new Dictionary<string, Func<IUserMessage, string, string>>()
{
{"%target%", (ctx, trigger) => { return ctx.Content.ToLowerInvariant().Substring(trigger.Length); } }
{"%target%", (ctx, trigger) => { return ctx.Content.Substring(trigger.Length).Trim(); } }
};
public static Dictionary<string, Func<IUserMessage, string>> placeholders = new Dictionary<string, Func<IUserMessage, string>>()

View File

@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Utility
`Joined Server:` **{user.JoinedAt?.ToString("dd.MM.yyyy HH:mm")}**
`Joined Discord:` **{user.CreatedAt.ToString("dd.MM.yyyy HH:mm")}**
`Roles:` **({user.Roles.Count()}) - {string.Join(", ", user.Roles.Select(r => r.Name)).SanitizeMentions()}**
`AvatarUrl:` **{user.AvatarUrl}**";
`AvatarUrl:` **{await NadekoBot.Google.ShortenUrl(user.AvatarUrl).ConfigureAwait(false)}**";
await msg.Reply(toReturn).ConfigureAwait(false);
}
}

View File

@ -1031,6 +1031,60 @@ namespace NadekoBot.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to chatmute.
/// </summary>
public static string chatmute_cmd {
get {
return ResourceManager.GetString("chatmute_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Prevents a mentioned user from chatting in text channels..
/// </summary>
public static string chatmute_desc {
get {
return ResourceManager.GetString("chatmute_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}chatmute @Someone`.
/// </summary>
public static string chatmute_usage {
get {
return ResourceManager.GetString("chatmute_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to chatunmute.
/// </summary>
public static string chatunmute_cmd {
get {
return ResourceManager.GetString("chatunmute_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Removes a mute role previously set on a mentioned user with `{0}chatmute` which prevented him from chatting in text channels..
/// </summary>
public static string chatunmute_desc {
get {
return ResourceManager.GetString("chatunmute_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}chatunmute @Someone`.
/// </summary>
public static string chatunmute_usage {
get {
return ResourceManager.GetString("chatunmute_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to checkmyperms.
/// </summary>
@ -3876,7 +3930,7 @@ namespace NadekoBot.Resources {
}
/// <summary>
/// Looks up a localized string similar to Moves permission from one position to another..
/// Looks up a localized string similar to Moves permission from one position to another in Permissions list..
/// </summary>
public static string moveperm_desc {
get {
@ -4713,7 +4767,7 @@ namespace NadekoBot.Resources {
}
/// <summary>
/// Looks up a localized string similar to Removes a permission from a given position.
/// Looks up a localized string similar to Removes a permission from a given position in Permissions list..
/// </summary>
public static string removeperm_desc {
get {
@ -6269,33 +6323,6 @@ namespace NadekoBot.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to textmute.
/// </summary>
public static string textmute_cmd {
get {
return ResourceManager.GetString("textmute_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Prevents a mentioned user from chatting in text channels..
/// </summary>
public static string textmute_desc {
get {
return ResourceManager.GetString("textmute_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}textmute @Someone`.
/// </summary>
public static string textmute_usage {
get {
return ResourceManager.GetString("textmute_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to tl.
/// </summary>
@ -6593,6 +6620,33 @@ namespace NadekoBot.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to unmute.
/// </summary>
public static string unmute_cmd {
get {
return ResourceManager.GetString("unmute_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unmutes a mentioned user previously muted with `{0}mute` command..
/// </summary>
public static string unmute_desc {
get {
return ResourceManager.GetString("unmute_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}unmute @Someone`.
/// </summary>
public static string unmute_usage {
get {
return ResourceManager.GetString("unmute_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to unstuck.
/// </summary>

View File

@ -2430,14 +2430,14 @@
<data name="antispam_usage" xml:space="preserve">
<value>`{0}antispam 3 Mute` or `{0}antispam 4 Kick` or `{0}antispam 6 Ban`</value>
</data>
<data name="textmute_cmd" xml:space="preserve">
<value>textmute</value>
<data name="chatmute_cmd" xml:space="preserve">
<value>chatmute</value>
</data>
<data name="textmute_desc" xml:space="preserve">
<data name="chatmute_desc" xml:space="preserve">
<value>Prevents a mentioned user from chatting in text channels.</value>
</data>
<data name="textmute_usage" xml:space="preserve">
<value>`{0}textmute @Someone`</value>
<data name="chatmute_usage" xml:space="preserve">
<value>`{0}chatmute @Someone`</value>
</data>
<data name="voicemute_cmd" xml:space="preserve">
<value>voicemute</value>
@ -2484,4 +2484,22 @@
<data name="setstream_usage" xml:space="preserve">
<value>`{0}setstream https://www.twitch.tv/masterkwoth Developing Nakedo`</value>
</data>
<data name="chatunmute_cmd" xml:space="preserve">
<value>chatunmute</value>
</data>
<data name="chatunmute_desc" xml:space="preserve">
<value>Removes a mute role previously set on a mentioned user with `{0}chatmute` which prevented him from chatting in text channels.</value>
</data>
<data name="chatunmute_usage" xml:space="preserve">
<value>`{0}chatunmute @Someone`</value>
</data>
<data name="unmute_cmd" xml:space="preserve">
<value>unmute</value>
</data>
<data name="unmute_desc" xml:space="preserve">
<value>Unmutes a mentioned user previously muted with `{0}mute` command.</value>
</data>
<data name="unmute_usage" xml:space="preserve">
<value>`{0}unmute @Someone`</value>
</data>
</root>