Removed some obsolete commands and strings

This commit is contained in:
Kwoth
2021-12-23 20:58:39 +01:00
parent 856dcd048a
commit 594a3b1f97
10 changed files with 36 additions and 119 deletions

View File

@@ -7,6 +7,8 @@ using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Common.Configs;
using NadekoBot.Db;
using NadekoBot.Modules.Administration.Services;
using Discord.Interactions;
using RunMode = Discord.Interactions.RunMode;
namespace NadekoBot;
@@ -16,7 +18,8 @@ public sealed class Bot
private readonly CommandService _commandService;
private readonly DbService _db;
private readonly IBotCredsProvider _credsProvider;
private readonly InteractionService _interactionService;
public event Func<GuildConfig, Task> JoinedGuild = delegate { return Task.CompletedTask; };
public DiscordSocketClient Client { get; }
@@ -57,9 +60,11 @@ public sealed class Bot
_commandService = new(new()
{
CaseSensitiveCommands = false,
DefaultRunMode = RunMode.Sync,
DefaultRunMode = Discord.Commands.RunMode.Sync,
});
_interactionService = new(Client.Rest);
#if GLOBAL_NADEKO || DEBUG
Client.Log += Client_Log;
#endif
@@ -89,6 +94,7 @@ public sealed class Bot
.AddRedis(_creds.RedisOptions) // redis
.AddSingleton(Client) // discord socket client
.AddSingleton(_commandService)
.AddSingleton(_interactionService)
.AddSingleton(this)
.AddSingleton<ISeria, JsonSeria>()
.AddSingleton<IPubSub, RedisPubSub>()
@@ -308,7 +314,8 @@ public sealed class Bot
await commandHandler.StartHandling().ConfigureAwait(false);
await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services);
await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services);
await _interactionService.RegisterCommandsToGuildAsync(117523346618318850);
IsReady = true;
_ = Task.Run(ExecuteReadySubscriptions);
Log.Information("Shard {ShardId} ready", Client.ShardId);

View File

@@ -14,10 +14,6 @@ public class FollowedStream : DbEntity
public enum FType
{
Twitch = 0,
[Obsolete("No longer supported.")]
Smashcast = 1,
[Obsolete("No longer supported.")]
Mixer = 2,
Picarto = 3,
Youtube = 4,
Facebook = 5,
@@ -35,13 +31,8 @@ public class FollowedStream : DbEntity
return HashCode.Combine(ChannelId, Username, (int) Type);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((FollowedStream) obj);
}
public override bool Equals(object obj)
=> obj is FollowedStream fs && Equals(fs);
public StreamDataKey CreateKey() =>
new StreamDataKey(Type, Username.ToLower());

View File

@@ -109,21 +109,6 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
All
}
[NadekoCommand, Aliases]
[Priority(0)]
public async Task ListCustReact(All _)
{
await ReplyPendingLocalizedAsync(strs.obsolete_use(Format.Code($"{Prefix}crsexport")));
await CrsExport();
}
[NadekoCommand, Aliases]
public async Task ListCustReactG(int page = 1)
{
await ReplyPendingLocalizedAsync(strs.obsolete_use(Format.Code($"{Prefix}crsexport")));
await CrsExport();
}
[NadekoCommand, Aliases]
public async Task ShowCustReact(kwum id)
{

View File

@@ -1,6 +1,12 @@
namespace NadekoBot.Modules.Gambling;
using Discord.Interactions;
public class TestGamblingService
namespace NadekoBot.Modules.Gambling;
public class TestGamblingService : InteractionModuleBase
{
[SlashCommand("test", "uwu")]
public async Task Test(string input1, int input2)
{
await RespondAsync("Bravo " + input1 + input2);
}
}

View File

@@ -499,14 +499,6 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ReplyConfirmLocalizedAsync(strs.repeating_track);
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ReptCurSong()
{
await ReplyPendingLocalizedAsync(strs.obsolete_use($"`{Prefix}qrp song`"));
await QueueRepeat(InputRepeatType.Song);
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Pause()

View File

@@ -1,45 +0,0 @@
using NadekoBot.Modules.Utility.Services;
namespace NadekoBot.Modules.Utility;
public partial class Utility
{
[Group]
public class PatreonCommands : NadekoSubmodule<PatreonRewardsService>
{
private readonly IBotCredentials _creds;
public PatreonCommands(IBotCredentials creds)
{
_creds = creds;
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.DM)]
public async Task ClaimPatreonRewards()
{
if (string.IsNullOrWhiteSpace(_creds.Patreon.AccessToken))
{
Log.Warning("In order to use patreon reward commands, " +
"you need to specify CampaignId and AccessToken in creds.yml");
return;
}
if (DateTime.UtcNow.Day < 5)
{
await ReplyErrorLocalizedAsync(strs.clpa_too_early).ConfigureAwait(false);
return;
}
var rem = _service.Interval - (DateTime.UtcNow - _service.LastUpdate);
var helpcmd = Format.Code(Prefix + "donate");
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
.WithDescription(GetText(strs.clpa_obsolete))
.AddField(GetText(strs.clpa_fail_already_title), GetText(strs.clpa_fail_already))
.AddField(GetText(strs.clpa_fail_wait_title), GetText(strs.clpa_fail_wait))
.AddField(GetText(strs.clpa_fail_conn_title), GetText(strs.clpa_fail_conn))
.AddField(GetText(strs.clpa_fail_sup_title), GetText(strs.clpa_fail_sup(helpcmd)))
.WithFooter(GetText(strs.clpa_next_update(rem))));
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Immutable;
using NadekoBot.Common.Configs;
using NadekoBot.Db;
using Discord.Interactions;
namespace NadekoBot.Services;
@@ -35,7 +36,8 @@ public class CommandHandler : INService
BotConfigService bss,
Bot bot,
IBehaviourExecutor behaviourExecutor,
IServiceProvider services)
IServiceProvider services,
InteractionService interactions)
{
_client = client;
_commandService = commandService;
@@ -44,6 +46,7 @@ public class CommandHandler : INService
_behaviourExecutor = behaviourExecutor;
_db = db;
_services = services;
_interactions = interactions;
_clearUsersOnShortCooldown = new(_ =>
{
@@ -121,12 +124,20 @@ public class CommandHandler : INService
public Task StartHandling()
{
_client.MessageReceived += msg => { var _ = Task.Run(() => MessageReceivedHandler(msg)); return Task.CompletedTask; };
_client.MessageReceived += MessageReceivedHandler;
_client.SlashCommandExecuted += SlashCommandExecuted;
return Task.CompletedTask;
}
private async Task SlashCommandExecuted(SocketSlashCommand arg)
{
var ctx = new SocketInteractionContext<SocketSlashCommand>(_client, arg);
await _interactions.ExecuteCommandAsync(ctx, _services);
}
private const float _oneThousandth = 1.0f / 1000;
private readonly DbService _db;
private readonly InteractionService _interactions;
private Task LogSuccessfulExecution(IUserMessage usrMsg, ITextChannel channel, params int[] execPoints)
{
@@ -264,7 +275,7 @@ public class CommandHandler : INService
return (false, null, null);
var commands = searchResult.Commands;
var preconditionResults = new Dictionary<CommandMatch, PreconditionResult>();
var preconditionResults = new Dictionary<CommandMatch, Discord.Commands.PreconditionResult>();
foreach (var match in commands)
{
@@ -352,7 +363,7 @@ public class CommandHandler : INService
//If we get this far, at least one parse was successful. Execute the most likely overload.
var chosenOverload = successfulParses[0];
var execResult = (ExecuteResult)await chosenOverload.Key.ExecuteAsync(context, chosenOverload.Value, services).ConfigureAwait(false);
var execResult = (Discord.Commands.ExecuteResult)await chosenOverload.Key.ExecuteAsync(context, chosenOverload.Value, services).ConfigureAwait(false);
if (execResult.Exception != null && (!(execResult.Exception is HttpException he) || he.DiscordCode != DiscordErrorCode.InsufficientPermissions))
{

View File

@@ -103,11 +103,6 @@ listcustreact:
- lcr
- exprli
- exl
listcustreactg:
- listcustreactg
- lcrg
- exprlg
- exlg
showcustreact:
- showcustreact
- scr
@@ -503,9 +498,6 @@ trackremove:
movesong:
- movesong
- ms
reptcursong:
- reptcursong
- rcs
queuerepeat:
- queuerepeat
- qrp
@@ -989,9 +981,6 @@ warnpunishlist:
warnpunish:
- warnpunish
- warnp
claimpatreonrewards:
- clparew
- claparew
ping:
- ping
time:

View File

@@ -862,10 +862,6 @@ setmaxqueue:
args:
- "50"
- ""
reptcursong:
desc: "Obsolete. Use `{0}queuerepeat`"
args:
- ""
queuerepeat:
desc: "Sets music player repeat strategy for this server.\n- `n` / `no` - player will stop once it reaches the end of the queue\n- `s` / `song` - player will repeat current song\n- `q` / `queue` or empty - player will repeat entire music queue"
args:
@@ -1685,10 +1681,6 @@ warnpunish:
- "5 Ban"
- "5 Mute 2d12h"
- "4 AddRole toxic 1h"
clparew:
desc: "Claim patreon rewards. If you're subscribed to bot owner's patreon you can use this command to claim your rewards - assuming bot owner did setup has their patreon key."
args:
- ""
ping:
desc: "Ping the bot to see if there are latency issues."
args:

View File

@@ -681,16 +681,6 @@
"warn_punish_rem": "Having {0} warnings will no longer trigger a punishment.",
"warn_punish_set": "I will apply {0} punishment to users with {1} warnings.",
"warn_punish_set_timed": "I will apply {0} punishment for {2} to users with {1} warnings.",
"clpa_obsolete": ":tada: **Patreon currency rewards are now automatic!** :tada:\nThis command is now obsolete.\nIf you did not receive your reward for this month's pledge, below are some of the reasons as to why that might be.",
"clpa_fail_already": "Maybe you've already received your reward for this month. You can receive rewards only once a month unless you increase your pledge.\nYou can check it by using `.curtrs` command.",
"clpa_fail_already_title": "Already rewarded",
"clpa_fail_conn": "Your discord account might not be connected to Patreon. If you are unsure what that means, or don't know how to connect it - you have to go to [Patreon account settings page](https://www.patreon.com/settings/apps) and click 'Connect to discord' button.",
"clpa_fail_conn_title": "Discord account not connected",
"clpa_fail_sup": "In order to be eligible for the reward, you must support the project on patreon. You can use {0} command to get the link.",
"clpa_fail_sup_title": "Not supporting",
"clpa_fail_wait": "You have to wait 5-10 minutes after making your pledge (and coonnecting your discord account to your patreon) for your currency to show up.",
"clpa_fail_wait_title": "Wait some time",
"clpa_too_early": "Rewards can be claimed on or after 5th of each month.",
"time_new": "Time",
"timezone": "Timezone",
"timezone_db_api_key": "You need to activate your TimezoneDB API key. You can do so by clicking on the link you've received in the email with your API key.",
@@ -701,7 +691,6 @@
"shop_none": "No shop items found on this page.",
"shop_role": "You will get {0} role.",
"type": "Type",
"clpa_next_update": "Next update in {0}",
"gvc_disabled": "Game Voice Channel feature has been disabled on this server.",
"gvc_enabled": "{0} is a Game Voice Channel now.",
"not_in_voice": "You are not in a voice channel on this server.",