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]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.Administrator)]
|
[RequirePermission(GuildPermission.Administrator)]
|
||||||
@ -257,9 +274,13 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
msg = "No reason provided.";
|
msg = "No reason provided.";
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
await (await user.CreateDMChannelAsync()).SendMessageAsync($"**You have been BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||||
$"Reason: {msg}").ConfigureAwait(false);
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
|
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
|
||||||
@ -282,13 +303,18 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
msg = "No reason provided.";
|
msg = "No reason provided.";
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
await user.SendMessageAsync($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
|
await user.SendMessageAsync($"**You have been SOFT-BANNED from `{channel.Guild.Name}` server.**\n" +
|
||||||
$"Reason: {msg}").ConfigureAwait(false);
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await channel.Guild.AddBanAsync(user, 7).ConfigureAwait(false);
|
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);
|
await channel.SendMessageAsync("Soft-Banned user " + user.Username + " Id: " + user.Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -311,10 +337,14 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
if (!string.IsNullOrWhiteSpace(msg))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await user.SendMessageAsync($"**You have been KICKED from `{channel.Guild.Name}` server.**\n" +
|
await user.SendMessageAsync($"**You have been KICKED from `{channel.Guild.Name}` server.**\n" +
|
||||||
$"Reason: {msg}").ConfigureAwait(false);
|
$"Reason: {msg}").ConfigureAwait(false);
|
||||||
await Task.Delay(2000).ConfigureAwait(false); // temp solution; give time for a message to be send, fu volt
|
await Task.Delay(2000).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -330,19 +360,51 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.MuteMembers)]
|
[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;
|
var channel = (ITextChannel)umsg.Channel;
|
||||||
|
|
||||||
if (!users.Any())
|
|
||||||
return;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var u in users)
|
await user.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
|
||||||
{
|
await user.AddRolesAsync(await GetMuteRole(channel.Guild).ConfigureAwait(false)).ConfigureAwait(false);
|
||||||
await u.ModifyAsync(usr => usr.Mute = true).ConfigureAwait(false);
|
await channel.SendMessageAsync($"**{user}** was text and voice muted successfully.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await channel.SendMessageAsync("Mute successful").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
|
catch
|
||||||
{
|
{
|
||||||
|
@ -252,19 +252,6 @@ namespace NadekoBot.Modules.Administration
|
|||||||
.ConfigureAwait(false);
|
.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]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequirePermission(GuildPermission.Administrator)]
|
[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>
|
/// <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>
|
/// </summary>
|
||||||
public static string mute_desc {
|
public static string mute_desc {
|
||||||
get {
|
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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to tl.
|
/// Looks up a localized string similar to tl.
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to voice+text v+t.
|
/// Looks up a localized string similar to voice+text v+t.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -616,7 +616,7 @@
|
|||||||
<value>mute</value>
|
<value>mute</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="mute_desc" xml:space="preserve">
|
<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>
|
||||||
<data name="mute_usage" xml:space="preserve">
|
<data name="mute_usage" xml:space="preserve">
|
||||||
<value>`.mute @Someone`</value>
|
<value>`.mute @Someone`</value>
|
||||||
@ -2664,4 +2664,22 @@
|
|||||||
<data name="antispam_usage" xml:space="preserve">
|
<data name="antispam_usage" xml:space="preserve">
|
||||||
<value>`.antispam 3 Mute` or `.antispam 4 Kick` or `.antispam 6 Ban`</value>
|
<value>`.antispam 3 Mute` or `.antispam 4 Kick` or `.antispam 6 Ban`</value>
|
||||||
</data>
|
</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>
|
</root>
|
Loading…
Reference in New Issue
Block a user