Added .voicemute .textmute and .mute is not voice and text mute
This commit is contained in:
parent
a75f0ab012
commit
a8ed07b2d4
@ -52,6 +52,23 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<IRole> GetMuteRole(IGuild guild)
|
||||
{
|
||||
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == "nadeko-mute");
|
||||
if (muteRole == null)
|
||||
{
|
||||
muteRole = await guild.CreateRoleAsync("nadeko-mute", GuildPermissions.None).ConfigureAwait(false);
|
||||
|
||||
foreach (var toOverwrite in guild.GetTextChannels())
|
||||
{
|
||||
await toOverwrite.AddPermissionOverwriteAsync(muteRole, new OverwritePermissions(sendMessages: PermValue.Deny, attachFiles: PermValue.Deny))
|
||||
.ConfigureAwait(false);
|
||||
await Task.Delay(200).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
return muteRole;
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequirePermission(GuildPermission.Administrator)]
|
||||
@ -257,9 +274,13 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
msg = "No reason provided.";
|
||||
}
|
||||
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||
try
|
||||
{
|
||||
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
|
||||
@ -282,13 +303,18 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
msg = "No reason provided.";
|
||||
}
|
||||
await user.SendMessageAsync($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||
try
|
||||
{
|
||||
await user.SendMessageAsync($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
|
||||
await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false);
|
||||
try { await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false); }
|
||||
catch { await channel.Guild.RemoveBanAsync(user).ConfigureAwait(false); }
|
||||
|
||||
await channel.SendMessageAsync("Soft-Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false);
|
||||
}
|
||||
@ -312,9 +338,13 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(msg))
|
||||
{
|
||||
await user.SendMessageAsync($"**You have been KICKED from `{channel.Guild.Name}` server.**\n" +
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
||||
try
|
||||
{
|
||||
await user.SendMessageAsync($"**You have been KICKED from `{channel.Guild.Name}` server.**\n" +
|
||||
$"Reason: {msg}").ConfigureAwait(false);
|
||||
await Task.Delay(2000).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
try
|
||||
{
|
||||
@ -330,19 +360,51 @@ namespace NadekoBot.Modules.Administration
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequirePermission(GuildPermission.MuteMembers)]
|
||||
public async Task Mute(IUserMessage umsg, params IGuildUser[] users)
|
||||
public async Task Mute(IUserMessage umsg, IGuildUser user)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
if (!users.Any())
|
||||
return;
|
||||
try
|
||||
{
|
||||
foreach (var u in users)
|
||||
{
|
||||
await u.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
|
||||
}
|
||||
await channel.SendMessageAsync("Mute successful").ConfigureAwait(false);
|
||||
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);
|
||||
}
|
||||
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.MuteMembers)]
|
||||
public async Task TextMute(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);
|
||||
}
|
||||
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.MuteMembers)]
|
||||
public async Task VoiceMute(IUserMessage umsg, IGuildUser user)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
try
|
||||
{
|
||||
await user.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
|
||||
await channel.SendMessageAsync($"**{user}** was voice muted successfully.").ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -252,19 +252,6 @@ namespace NadekoBot.Modules.Administration
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<IRole> GetMuteRole(IGuild guild)
|
||||
{
|
||||
var muteRole = guild.Roles.FirstOrDefault(r => r.Name == "nadeko-mute") ??
|
||||
await guild.CreateRoleAsync("nadeko-mute", GuildPermissions.None).ConfigureAwait(false);
|
||||
foreach (var toOverwrite in guild.GetTextChannels())
|
||||
{
|
||||
await toOverwrite.AddPermissionOverwriteAsync(muteRole, new OverwritePermissions(sendMessages: PermValue.Deny, attachFiles: PermValue.Deny))
|
||||
.ConfigureAwait(false);
|
||||
await Task.Delay(200).ConfigureAwait(false);
|
||||
}
|
||||
return muteRole;
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequirePermission(GuildPermission.Administrator)]
|
||||
|
56
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
56
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -4308,7 +4308,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Mutes a mentioned user in a voice channel..
|
||||
/// Looks up a localized string similar to Mutes a mentioned user both fom speaking and chatting..
|
||||
/// </summary>
|
||||
public static string mute_desc {
|
||||
get {
|
||||
@ -6755,6 +6755,33 @@ 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 `.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>
|
||||
@ -7457,6 +7484,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to voicemute.
|
||||
/// </summary>
|
||||
public static string voicemute_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("voicemute_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Prevents a mentioned user from speaking in voice channels..
|
||||
/// </summary>
|
||||
public static string voicemute_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("voicemute_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `.voicemute @Someone`.
|
||||
/// </summary>
|
||||
public static string voicemute_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("voicemute_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to voice+text v+t.
|
||||
/// </summary>
|
||||
|
@ -616,7 +616,7 @@
|
||||
<value>mute</value>
|
||||
</data>
|
||||
<data name="mute_desc" xml:space="preserve">
|
||||
<value>Mutes a mentioned user in a voice channel.</value>
|
||||
<value>Mutes a mentioned user both fom speaking and chatting.</value>
|
||||
</data>
|
||||
<data name="mute_usage" xml:space="preserve">
|
||||
<value>`.mute @Someone`</value>
|
||||
@ -2664,4 +2664,22 @@
|
||||
<data name="antispam_usage" xml:space="preserve">
|
||||
<value>`.antispam 3 Mute` or `.antispam 4 Kick` or `.antispam 6 Ban`</value>
|
||||
</data>
|
||||
<data name="textmute_cmd" xml:space="preserve">
|
||||
<value>textmute</value>
|
||||
</data>
|
||||
<data name="textmute_desc" xml:space="preserve">
|
||||
<value>Prevents a mentioned user from chatting in text channels.</value>
|
||||
</data>
|
||||
<data name="textmute_usage" xml:space="preserve">
|
||||
<value>`.textmute @Someone`</value>
|
||||
</data>
|
||||
<data name="voicemute_cmd" xml:space="preserve">
|
||||
<value>voicemute</value>
|
||||
</data>
|
||||
<data name="voicemute_desc" xml:space="preserve">
|
||||
<value>Prevents a mentioned user from speaking in voice channels.</value>
|
||||
</data>
|
||||
<data name="voicemute_usage" xml:space="preserve">
|
||||
<value>`.voicemute @Someone`</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user