mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
added: Added .afk <msg>?
command which sets an afk message which will trigger whenever someone pings a user.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#nullable disable
|
||||
using LinqToDB.Reflection;
|
||||
using NadekoBot.Modules.Utility.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System.Diagnostics;
|
||||
@@ -7,6 +7,7 @@ using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.CodeAnalysis.CSharp.Scripting;
|
||||
using Microsoft.CodeAnalysis.Scripting;
|
||||
using NadekoBot.Modules.Games.Hangman;
|
||||
using NadekoBot.Modules.Searches.Common;
|
||||
|
||||
namespace NadekoBot.Modules.Utility;
|
||||
@@ -41,6 +42,7 @@ public partial class Utility : NadekoModule
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly VerboseErrorsService _veService;
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly AfkService _afkService;
|
||||
|
||||
public Utility(
|
||||
DiscordSocketClient client,
|
||||
@@ -50,7 +52,8 @@ public partial class Utility : NadekoModule
|
||||
DownloadTracker tracker,
|
||||
IHttpClientFactory httpFactory,
|
||||
VerboseErrorsService veService,
|
||||
IServiceProvider services)
|
||||
IServiceProvider services,
|
||||
AfkService afkService)
|
||||
{
|
||||
_client = client;
|
||||
_coord = coord;
|
||||
@@ -60,6 +63,7 @@ public partial class Utility : NadekoModule
|
||||
_httpFactory = httpFactory;
|
||||
_veService = veService;
|
||||
_services = services;
|
||||
_afkService = afkService;
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -99,7 +103,7 @@ public partial class Utility : NadekoModule
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task WhosPlaying([Leftover] string game)
|
||||
public async Task WhosPlaying([Leftover] string? game)
|
||||
{
|
||||
game = game?.Trim().ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(game))
|
||||
@@ -140,7 +144,7 @@ public partial class Utility : NadekoModule
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(0)]
|
||||
public async Task InRole(int page, [Leftover] IRole role = null)
|
||||
public async Task InRole(int page, [Leftover] IRole? role = null)
|
||||
{
|
||||
if (--page < 0)
|
||||
return;
|
||||
@@ -178,7 +182,7 @@ public partial class Utility : NadekoModule
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(1)]
|
||||
public Task InRole([Leftover] IRole role = null)
|
||||
public Task InRole([Leftover] IRole? role = null)
|
||||
=> InRole(1, role);
|
||||
|
||||
[Cmd]
|
||||
@@ -218,7 +222,7 @@ public partial class Utility : NadekoModule
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task UserId([Leftover] IGuildUser target = null)
|
||||
public async Task UserId([Leftover] IGuildUser? target = null)
|
||||
{
|
||||
var usr = target ?? ctx.User;
|
||||
await Response()
|
||||
@@ -248,7 +252,7 @@ public partial class Utility : NadekoModule
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Roles(IGuildUser target, int page = 1)
|
||||
public async Task Roles(IGuildUser? target, int page = 1)
|
||||
{
|
||||
var guild = ctx.Guild;
|
||||
|
||||
@@ -301,7 +305,7 @@ public partial class Utility : NadekoModule
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ChannelTopic([Leftover] ITextChannel channel = null)
|
||||
public async Task ChannelTopic([Leftover] ITextChannel? channel = null)
|
||||
{
|
||||
if (channel is null)
|
||||
channel = (ITextChannel)ctx.Channel;
|
||||
@@ -382,7 +386,7 @@ public partial class Utility : NadekoModule
|
||||
[BotPerm(GuildPerm.ManageEmojisAndStickers)]
|
||||
[UserPerm(GuildPerm.ManageEmojisAndStickers)]
|
||||
[Priority(0)]
|
||||
public async Task EmojiAdd(string name, string url = null)
|
||||
public async Task EmojiAdd(string name, string? url = null)
|
||||
{
|
||||
name = name.Trim(':');
|
||||
|
||||
@@ -456,10 +460,10 @@ public partial class Utility : NadekoModule
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[BotPerm(GuildPerm.ManageEmojisAndStickers)]
|
||||
[UserPerm(GuildPerm.ManageEmojisAndStickers)]
|
||||
public async Task StickerAdd(string name = null, string description = null, params string[] tags)
|
||||
public async Task StickerAdd(string? name = null, string? description = null, params string[] tags)
|
||||
{
|
||||
string format;
|
||||
Stream stream = null;
|
||||
Stream? stream = null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -696,6 +700,19 @@ public partial class Utility : NadekoModule
|
||||
await Response().Confirm(strs.verbose_errors_disabled).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
public async Task Afk([Leftover] string text = "No reason specified.")
|
||||
{
|
||||
var succ = await _afkService.SetAfkAsync(ctx.User.Id, text);
|
||||
|
||||
if (succ)
|
||||
{
|
||||
await Response()
|
||||
.Confirm(strs.afk_set)
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[NoPublicBot]
|
||||
[OwnerOnly]
|
||||
|
Reference in New Issue
Block a user