mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7d5c4666b8 |
81
CHANGELOG.md
81
CHANGELOG.md
@@ -4,87 +4,6 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
|
||||
## Unreleased
|
||||
|
||||
## [4.3.8] - 02.10.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.autopublish` command which will automatically publish messages posted in the channel.
|
||||
- Added `--after <messageid>` option to prune which will make prune only delete messages after the specified message id.
|
||||
|
||||
### Changed
|
||||
|
||||
- `.prune` options `--after` and `--safe` are now proper command options, and will show in .h help
|
||||
- `.cmdcd` code mostly rewritten, slight QoL improvements.
|
||||
- Clarified `.remind` permission requirements in help text
|
||||
- `.cmdcds` looks a little better, and is paginated
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed trivia bugs
|
||||
- Fixed `.yun` not working with channels with underscore in the name
|
||||
|
||||
## [4.3.7] - 14.09.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.exprdelserv` (.exds) to completement .exas. Deletes an expression on the current server and is susceptible to .dpo, unlike .exd
|
||||
- Added `.shopreq` which lets you set role requirement for specific shop items
|
||||
- Added `.shopbuy` alias to `.buy`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.convertlist` showing currencies twice (this may not apply to existing users and it may require you to manually remove all currencies from units.json)
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed `Viewer` field from stream online notification as it is (almost?) always 0.
|
||||
|
||||
## [4.3.6] - 08.09.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.expraddserver` (.exas) which will server as a server-only alternative to '.exa' in case users want to override default Admin permissions with .dpo
|
||||
- Added .banprune command which sets how many days worth of messages will be pruned when bot (soft)bans a person either through a command or another punishment feature.
|
||||
- Added .qdelauth - Delete all quotes by the specified author on this server. If you target yourself - no permission required
|
||||
- Added `.timeout` command
|
||||
- Added an option to award currency based on received xp
|
||||
|
||||
### Changed
|
||||
|
||||
- Reminders now have embed support, but plaintext field is not supported.
|
||||
- User friendlier errors when parsing a number in a command fails
|
||||
|
||||
### Fixed
|
||||
|
||||
- Awarded xp is now correctly used in level up calculations
|
||||
|
||||
## [4.3.5] - 17.08.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added a 'Use' button when a user already owns an item
|
||||
- Added a 'Pull Again' button to slots
|
||||
- Added `.roleinfo` command
|
||||
- Added `.emojiremove` command
|
||||
- Added `.threadcreate` and `.threaddelete` commands
|
||||
- Added `.bank seize` / `.bank award` owner only commands
|
||||
|
||||
### Changed
|
||||
|
||||
- Running a .timely command early now shows a pending color
|
||||
- .xp system is once again no longer opt in for servers
|
||||
- It's still opt-in for global and requires users to run .xp at least once in order to start gaining global xp
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed users not getting club xp
|
||||
|
||||
## [4.3.4] - 07.08.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed users getting XP out of nowhere while voice xp is enabled
|
||||
|
||||
## [4.3.3] - 06.08.2022
|
||||
|
||||
### Added
|
||||
|
@@ -1,3 +1,8 @@
|
||||
[](https://discord.gg/nadekobot)
|
||||
[](http://nadekobot.readthedocs.io/en/v4/?badge=v4)
|
||||
[](https://top.gg/bot/116275390695079945)
|
||||
|
||||
|
||||
[](https://nadeko.bot/)
|
||||
|
||||
[](https://invite.nadeko.bot/)
|
||||
|
@@ -33,14 +33,14 @@ These are required for a number of features to function properly, and all should
|
||||
For a single owner, it should look like this:
|
||||
|
||||
```yml
|
||||
OwnerIds:
|
||||
OwnerIds:
|
||||
- 105635576866156544
|
||||
```
|
||||
|
||||
For multiple owners, it should look like this:
|
||||
|
||||
```yml
|
||||
OwnerIds:
|
||||
OwnerIds:
|
||||
- 105635123466156544
|
||||
- 145521851676884992
|
||||
- 341420590009417729
|
||||
|
@@ -1,4 +1,4 @@
|
||||
w# Setting up NadekoBot on Linux
|
||||
# Setting up NadekoBot on Linux
|
||||
|
||||
| Table of Contents |
|
||||
| :-------------------------------------------------- |
|
||||
@@ -17,7 +17,7 @@ It is recommended that you use **Ubuntu 20.04**, as there have been nearly no pr
|
||||
|
||||
##### Compatible operating systems:
|
||||
|
||||
- Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10, 22.04
|
||||
- Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10 22.04
|
||||
- Mint: 19, 20
|
||||
- Debian: 9, 10
|
||||
- CentOS: 7
|
||||
@@ -160,30 +160,15 @@ If you are presented with the installer main menu, exit it by choosing Option `8
|
||||
|
||||
The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer, it's your session name)*.
|
||||
|
||||
2. Run the installer: `bash linuxAIO.sh`
|
||||
|
||||
3. There are a few options when it comes to running Nadeko.
|
||||
|
||||
- Run `3` to *Run the bot normally*
|
||||
- Run `4` to *Run the bot with Auto Restart* (This is may or may not work)
|
||||
|
||||
4. If option `4` was selected, you have the following options
|
||||
```
|
||||
1. Run Auto Restart normally without updating NadekoBot.
|
||||
2. Run Auto Restart and update NadekoBot.
|
||||
3. Exit
|
||||
|
||||
Choose:
|
||||
[1] to Run NadekoBot with Auto Restart on "die" command without updating.
|
||||
[2] to Run with Auto Updating on restart after using "die" command.
|
||||
```
|
||||
- Run `1` to update the bot upon restart. (This is done using the `.die` command)
|
||||
- Run `2` to restart the bot without updating. (This is also done using the `.die` command)
|
||||
|
||||
5. That's it! to detatch the tmux session:
|
||||
2. Navigate to the project's root directory
|
||||
- Project root directory location example: `cd /home/user/nadekobot/`
|
||||
3. Enter the `output` directory:
|
||||
- `cd output`
|
||||
4. Run the bot using:
|
||||
- `dotnet NadekoBot.dll`
|
||||
5. Detatch the tmux session:
|
||||
- Press `Ctrl` + `B`
|
||||
- Then press `D`
|
||||
|
||||
Now check your Discord server, the bot should be online. Nadeko should now be running in the background of your system.
|
||||
|
||||
To re-open the tmux session to either update, restart, or whatever, execute `tmux a -t nadeko`. *(Make sure to replace "nadeko" with your session name. If you didn't change it, leave it as it.)*
|
||||
@@ -316,26 +301,6 @@ This method is similar to the one above, but requires one extra step, with the a
|
||||
|
||||
If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (by using this link, you will get **$10 credit** and also support Nadeko)
|
||||
|
||||
To set up the VPS, please select the options below
|
||||
```
|
||||
These are the min requirements you must follow:
|
||||
|
||||
OS: Any between Ubuntu, Fedora, and Debian
|
||||
|
||||
Plan: Basic
|
||||
|
||||
CPU options: regular with SSD
|
||||
1 GB / 1 CPU
|
||||
25 GB SSD Disk
|
||||
1000 GB transfer
|
||||
|
||||
Note: You can select the cheapest option with 512 MB /1 CPU but this has been a hit or miss.
|
||||
|
||||
Datacenter region: Choose one depending on where you are located.
|
||||
|
||||
Authentication: Password or SSH
|
||||
(Select SSH if you know what you are doing, otherwise choose password)
|
||||
```
|
||||
**Setting up NadekoBot**
|
||||
Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started.
|
||||
|
||||
|
@@ -1,8 +1,5 @@
|
||||
namespace Nadeko.Econ.Gambling;
|
||||
|
||||
//here is a payout chart
|
||||
//https://lh6.googleusercontent.com/-i1hjAJy_kN4/UswKxmhrbPI/AAAAAAAAB1U/82wq_4ZZc-Y/DE6B0895-6FC1-48BE-AC4F-14D1B91AB75B.jpg
|
||||
//thanks to judge for helping me with this
|
||||
public class SlotGame
|
||||
{
|
||||
private static readonly NadekoRandom _rng = new NadekoRandom();
|
||||
|
@@ -10,7 +10,6 @@ public interface IEmbedBuilder
|
||||
IEmbedBuilder WithFooter(string text, string? iconUrl = null);
|
||||
IEmbedBuilder WithAuthor(string name, string? iconUrl = null, string? url = null);
|
||||
IEmbedBuilder WithColor(EmbedColor color);
|
||||
IEmbedBuilder WithDiscordColor(Color color);
|
||||
Embed Build();
|
||||
IEmbedBuilder WithUrl(string url);
|
||||
IEmbedBuilder WithImageUrl(string url);
|
||||
|
@@ -12,7 +12,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.104.0" />
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.103.0" />
|
||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
</ItemGroup>
|
||||
|
@@ -3,12 +3,14 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using NadekoBot.Common.Configs;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Modules.Administration;
|
||||
using NadekoBot.Modules.Utility;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using Nadeko.Common;
|
||||
using RunMode = Discord.Commands.RunMode;
|
||||
|
||||
namespace NadekoBot;
|
||||
@@ -116,6 +118,10 @@ public sealed class Bot
|
||||
// cache
|
||||
.AddCache(_creds);
|
||||
|
||||
// admin
|
||||
#if GLOBAL_NADEKO
|
||||
svcs.AddSingleton<ILogCommandService, DummyLogCommandService>();
|
||||
#endif
|
||||
|
||||
svcs.AddHttpClient();
|
||||
svcs.AddHttpClient("memelist")
|
||||
|
@@ -1,8 +0,0 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
public interface INadekoInteractionService
|
||||
{
|
||||
public NadekoInteraction Create<T>(
|
||||
ulong userId,
|
||||
SimpleInteraction<T> inter);
|
||||
}
|
29
src/NadekoBot/Common/Interaction/NadekoActionInteraction.cs
Normal file
29
src/NadekoBot/Common/Interaction/NadekoActionInteraction.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
public sealed class NadekoButtonActionInteraction : NadekoButtonOwnInteraction
|
||||
{
|
||||
private readonly NadekoInteractionData _data;
|
||||
private readonly Func<SocketMessageComponent, Task> _action;
|
||||
|
||||
public NadekoButtonActionInteraction(
|
||||
DiscordSocketClient client,
|
||||
ulong authorId,
|
||||
NadekoInteractionData data,
|
||||
Func<SocketMessageComponent, Task> action
|
||||
)
|
||||
: base(client, authorId)
|
||||
{
|
||||
_data = data;
|
||||
_action = action;
|
||||
}
|
||||
|
||||
protected override string Name
|
||||
=> _data.CustomId;
|
||||
protected override IEmote Emote
|
||||
=> _data.Emote;
|
||||
protected override string? Text
|
||||
=> _data.Text;
|
||||
|
||||
public override Task ExecuteOnActionAsync(SocketMessageComponent smc)
|
||||
=> _action(smc);
|
||||
}
|
@@ -1,30 +1,25 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
public sealed class NadekoInteraction
|
||||
public abstract class NadekoButtonInteraction
|
||||
{
|
||||
private readonly ulong _authorId;
|
||||
private readonly ButtonBuilder _button;
|
||||
private readonly Func<SocketMessageComponent, Task> _onClick;
|
||||
private readonly bool _onlyAuthor;
|
||||
// improvements:
|
||||
// - state in OnAction
|
||||
// - configurable delay
|
||||
// -
|
||||
protected abstract string Name { get; }
|
||||
protected abstract IEmote Emote { get; }
|
||||
protected virtual string? Text { get; } = null;
|
||||
|
||||
public DiscordSocketClient Client { get; }
|
||||
|
||||
private readonly TaskCompletionSource<bool> _interactionCompletedSource;
|
||||
protected readonly TaskCompletionSource<bool> _interactionCompletedSource;
|
||||
|
||||
private IUserMessage message = null!;
|
||||
protected IUserMessage message = null!;
|
||||
|
||||
public NadekoInteraction(DiscordSocketClient client,
|
||||
ulong authorId,
|
||||
ButtonBuilder button,
|
||||
Func<SocketMessageComponent, Task> onClick,
|
||||
bool onlyAuthor)
|
||||
protected NadekoButtonInteraction(DiscordSocketClient client)
|
||||
{
|
||||
_authorId = authorId;
|
||||
_button = button;
|
||||
_onClick = onClick;
|
||||
_onlyAuthor = onlyAuthor;
|
||||
_interactionCompletedSource = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
Client = client;
|
||||
_interactionCompletedSource = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
|
||||
public async Task RunAsync(IUserMessage msg)
|
||||
@@ -32,25 +27,29 @@ public sealed class NadekoInteraction
|
||||
message = msg;
|
||||
|
||||
Client.InteractionCreated += OnInteraction;
|
||||
await Task.WhenAny(Task.Delay(15_000), _interactionCompletedSource.Task);
|
||||
await Task.WhenAny(Task.Delay(10_000), _interactionCompletedSource.Task);
|
||||
Client.InteractionCreated -= OnInteraction;
|
||||
|
||||
await msg.ModifyAsync(m => m.Components = new ComponentBuilder().Build());
|
||||
}
|
||||
|
||||
private Task OnInteraction(SocketInteraction arg)
|
||||
protected abstract ValueTask<bool> Validate(SocketMessageComponent smc);
|
||||
private async Task OnInteraction(SocketInteraction arg)
|
||||
{
|
||||
if (arg is not SocketMessageComponent smc)
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
|
||||
if (smc.Message.Id != message.Id)
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
|
||||
if (_onlyAuthor && smc.User.Id != _authorId)
|
||||
return Task.CompletedTask;
|
||||
if (smc.Data.CustomId != Name)
|
||||
return;
|
||||
|
||||
if (smc.Data.CustomId != _button.CustomId)
|
||||
return Task.CompletedTask;
|
||||
if (!await Validate(smc))
|
||||
{
|
||||
await smc.DeferAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
@@ -64,19 +63,21 @@ public sealed class NadekoInteraction
|
||||
await smc.DeferAsync();
|
||||
}
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
public MessageComponent CreateComponent()
|
||||
public virtual MessageComponent CreateComponent()
|
||||
{
|
||||
var comp = new ComponentBuilder()
|
||||
.WithButton(_button);
|
||||
.WithButton(GetButtonBuilder());
|
||||
|
||||
return comp.Build();
|
||||
}
|
||||
|
||||
public Task ExecuteOnActionAsync(SocketMessageComponent smc)
|
||||
=> _onClick(smc);
|
||||
public ButtonBuilder GetButtonBuilder()
|
||||
=> new ButtonBuilder(style: ButtonStyle.Secondary, emote: Emote, customId: Name, label: Text);
|
||||
|
||||
public abstract Task ExecuteOnActionAsync(SocketMessageComponent smc);
|
||||
}
|
||||
|
||||
// this is all so wrong ...
|
43
src/NadekoBot/Common/Interaction/NadekoInteractionArray.cs
Normal file
43
src/NadekoBot/Common/Interaction/NadekoInteractionArray.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
// namespace NadekoBot;
|
||||
//
|
||||
// public class NadekoButtonInteractionArray : NadekoButtonInteraction
|
||||
// {
|
||||
// private readonly ButtonBuilder[] _bbs;
|
||||
// private readonly NadekoButtonInteraction[] _inters;
|
||||
//
|
||||
// public NadekoButtonInteractionArray(params NadekoButtonInteraction[] inters)
|
||||
// : base(inters[0].Client)
|
||||
// {
|
||||
// _inters = inters;
|
||||
// _bbs = inters.Map(x => x.GetButtonBuilder());
|
||||
// }
|
||||
//
|
||||
// protected override string Name
|
||||
// => throw new NotSupportedException();
|
||||
// protected override IEmote Emote
|
||||
// => throw new NotSupportedException();
|
||||
//
|
||||
// protected override ValueTask<bool> Validate(SocketMessageComponent smc)
|
||||
// => new(true);
|
||||
//
|
||||
// public override Task ExecuteOnActionAsync(SocketMessageComponent smc)
|
||||
// {
|
||||
// for (var i = 0; i < _bbs.Length; i++)
|
||||
// {
|
||||
// if (_bbs[i].CustomId == smc.Data.CustomId)
|
||||
// return _inters[i].ExecuteOnActionAsync(smc);
|
||||
// }
|
||||
//
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//
|
||||
// public override MessageComponent CreateComponent()
|
||||
// {
|
||||
// var comp = new ComponentBuilder();
|
||||
//
|
||||
// foreach (var bb in _bbs)
|
||||
// comp.WithButton(bb);
|
||||
//
|
||||
// return comp.Build();
|
||||
// }
|
||||
// }
|
42
src/NadekoBot/Common/Interaction/NadekoInteractionBuilder.cs
Normal file
42
src/NadekoBot/Common/Interaction/NadekoInteractionBuilder.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
/// <summary>
|
||||
/// Builder class for NadekoInteractions
|
||||
/// </summary>
|
||||
public class NadekoInteractionBuilder
|
||||
{
|
||||
private NadekoInteractionData? iData;
|
||||
private Func<SocketMessageComponent, Task>? action;
|
||||
// private bool isOwn;
|
||||
|
||||
public NadekoInteractionBuilder WithData<T>(in T data)
|
||||
where T : NadekoInteractionData
|
||||
{
|
||||
iData = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
// public NadekoOwnInteractionBuiler WithIsOwn(bool isOwn = true)
|
||||
// {
|
||||
// this.isOwn = isOwn;
|
||||
// return this;
|
||||
|
||||
// }
|
||||
|
||||
public NadekoInteractionBuilder WithAction(in Func<SocketMessageComponent, Task> fn)
|
||||
{
|
||||
this.action = fn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NadekoButtonActionInteraction Build(DiscordSocketClient client, ulong userId)
|
||||
{
|
||||
if (iData is null)
|
||||
throw new InvalidOperationException("You have to specify the data before building the interaction");
|
||||
|
||||
if (action is null)
|
||||
throw new InvalidOperationException("You have to specify the action before building the interaction");
|
||||
|
||||
return new(client, userId, iData, action);
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
public class NadekoInteractionService : INadekoInteractionService, INService
|
||||
{
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public NadekoInteractionService(DiscordSocketClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public NadekoInteraction Create<T>(
|
||||
ulong userId,
|
||||
SimpleInteraction<T> inter)
|
||||
=> new NadekoInteraction(_client,
|
||||
userId,
|
||||
inter.Button,
|
||||
inter.TriggerAsync,
|
||||
onlyAuthor: true);
|
||||
}
|
15
src/NadekoBot/Common/Interaction/NadekoOwnInteraction.cs
Normal file
15
src/NadekoBot/Common/Interaction/NadekoOwnInteraction.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction which only the author can use
|
||||
/// </summary>
|
||||
public abstract class NadekoButtonOwnInteraction : NadekoButtonInteraction
|
||||
{
|
||||
protected readonly ulong _authorId;
|
||||
|
||||
protected NadekoButtonOwnInteraction(DiscordSocketClient client, ulong authorId) : base(client)
|
||||
=> _authorId = authorId;
|
||||
|
||||
protected override ValueTask<bool> Validate(SocketMessageComponent smc)
|
||||
=> new(smc.User.Id == _authorId);
|
||||
}
|
26
src/NadekoBot/Common/NInteraction.cs
Normal file
26
src/NadekoBot/Common/NInteraction.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public abstract class NInteraction
|
||||
{
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly ulong _userId;
|
||||
private readonly Func<SocketMessageComponent, Task> _action;
|
||||
|
||||
protected abstract NadekoInteractionData Data { get; }
|
||||
|
||||
public NInteraction(
|
||||
DiscordSocketClient client,
|
||||
ulong userId,
|
||||
Func<SocketMessageComponent, Task> action)
|
||||
{
|
||||
_client = client;
|
||||
_userId = userId;
|
||||
_action = action;
|
||||
}
|
||||
|
||||
public NadekoButtonInteraction GetInteraction()
|
||||
=> new NadekoInteractionBuilder()
|
||||
.WithData(Data)
|
||||
.WithAction(_action)
|
||||
.Build(_client, _userId);
|
||||
}
|
@@ -18,7 +18,6 @@ public abstract class NadekoModule : ModuleBase
|
||||
public CommandHandler _cmdHandler { get; set; }
|
||||
public ILocalization _localization { get; set; }
|
||||
public IEmbedBuilderService _eb { get; set; }
|
||||
public INadekoInteractionService _inter { get; set; }
|
||||
|
||||
protected string prefix
|
||||
=> _cmdHandler.GetPrefix(ctx.Guild);
|
||||
@@ -37,7 +36,7 @@ public abstract class NadekoModule : ModuleBase
|
||||
string error,
|
||||
string url = null,
|
||||
string footer = null,
|
||||
NadekoInteraction inter = null)
|
||||
NadekoButtonInteraction inter = null)
|
||||
=> ctx.Channel.SendErrorAsync(_eb, title, error, url, footer);
|
||||
|
||||
public Task<IUserMessage> SendConfirmAsync(
|
||||
@@ -48,32 +47,32 @@ public abstract class NadekoModule : ModuleBase
|
||||
=> ctx.Channel.SendConfirmAsync(_eb, title, text, url, footer);
|
||||
|
||||
//
|
||||
public Task<IUserMessage> SendErrorAsync(string text, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> SendErrorAsync(string text, NadekoButtonInteraction inter = null)
|
||||
=> ctx.Channel.SendAsync(_eb, text, MessageType.Error, inter);
|
||||
public Task<IUserMessage> SendConfirmAsync(string text, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> SendConfirmAsync(string text, NadekoButtonInteraction inter = null)
|
||||
=> ctx.Channel.SendAsync(_eb, text, MessageType.Ok, inter);
|
||||
public Task<IUserMessage> SendPendingAsync(string text, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> SendPendingAsync(string text, NadekoButtonInteraction inter = null)
|
||||
=> ctx.Channel.SendAsync(_eb, text, MessageType.Pending, inter);
|
||||
|
||||
|
||||
// localized normal
|
||||
public Task<IUserMessage> ErrorLocalizedAsync(LocStr str, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> ErrorLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
|
||||
=> SendErrorAsync(GetText(str), inter);
|
||||
|
||||
public Task<IUserMessage> PendingLocalizedAsync(LocStr str, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> PendingLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
|
||||
=> SendPendingAsync(GetText(str), inter);
|
||||
|
||||
public Task<IUserMessage> ConfirmLocalizedAsync(LocStr str, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> ConfirmLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
|
||||
=> SendConfirmAsync(GetText(str), inter);
|
||||
|
||||
// localized replies
|
||||
public Task<IUserMessage> ReplyErrorLocalizedAsync(LocStr str, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> ReplyErrorLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
|
||||
=> SendErrorAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter);
|
||||
|
||||
public Task<IUserMessage> ReplyPendingLocalizedAsync(LocStr str, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> ReplyPendingLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
|
||||
=> SendPendingAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter);
|
||||
|
||||
public Task<IUserMessage> ReplyConfirmLocalizedAsync(LocStr str, NadekoInteraction inter = null)
|
||||
public Task<IUserMessage> ReplyConfirmLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
|
||||
=> SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter);
|
||||
|
||||
public async Task<bool> PromptUserConfirmAsync(IEmbedBuilder embed)
|
||||
|
@@ -1,33 +0,0 @@
|
||||
namespace NadekoBot.Common.TypeReaders;
|
||||
|
||||
public sealed class GuildUserTypeReader : NadekoTypeReader<IGuildUser>
|
||||
{
|
||||
public override async ValueTask<TypeReaderResult<IGuildUser>> ReadAsync(ICommandContext ctx, string input)
|
||||
{
|
||||
if (ctx.Guild is null)
|
||||
return TypeReaderResult.FromError<IGuildUser>(CommandError.Unsuccessful, "Must be in a guild.");
|
||||
|
||||
input = input.Trim();
|
||||
IGuildUser? user = null;
|
||||
if (MentionUtils.TryParseUser(input, out var id))
|
||||
user = await ctx.Guild.GetUserAsync(id, CacheMode.AllowDownload);
|
||||
|
||||
if (ulong.TryParse(input, out id))
|
||||
user = await ctx.Guild.GetUserAsync(id, CacheMode.AllowDownload);
|
||||
|
||||
if (user is null)
|
||||
{
|
||||
var users = await ctx.Guild.GetUsersAsync(CacheMode.CacheOnly);
|
||||
user = users.FirstOrDefault(x => x.Username == input)
|
||||
?? users.FirstOrDefault(x =>
|
||||
string.Equals(x.ToString(), input, StringComparison.InvariantCultureIgnoreCase))
|
||||
?? users.FirstOrDefault(x =>
|
||||
string.Equals(x.Username, input, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
if (user is null)
|
||||
return TypeReaderResult.FromError<IGuildUser>(CommandError.ObjectNotFound, "User not found.");
|
||||
|
||||
return TypeReaderResult.FromSuccess(user);
|
||||
}
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
#nullable disable
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
@@ -7,14 +6,12 @@ namespace NadekoBot.Db;
|
||||
|
||||
public static class CurrencyTransactionExtensions
|
||||
{
|
||||
public static Task<List<CurrencyTransaction>> GetPageFor(
|
||||
this DbSet<CurrencyTransaction> set,
|
||||
ulong userId,
|
||||
int page)
|
||||
=> set.ToLinqToDBTable()
|
||||
public static List<CurrencyTransaction> GetPageFor(this DbSet<CurrencyTransaction> set, ulong userId, int page)
|
||||
=> set.AsQueryable()
|
||||
.AsNoTracking()
|
||||
.Where(x => x.UserId == userId)
|
||||
.OrderByDescending(x => x.DateAdded)
|
||||
.Skip(15 * page)
|
||||
.Take(15)
|
||||
.ToListAsyncLinqToDB();
|
||||
.ToList();
|
||||
}
|
@@ -49,8 +49,7 @@ public enum PunishmentAction
|
||||
ChatMute,
|
||||
VoiceMute,
|
||||
AddRole,
|
||||
Warn,
|
||||
TimeOut
|
||||
Warn
|
||||
}
|
||||
|
||||
public class AntiSpamIgnore : DbEntity
|
||||
|
@@ -1,9 +0,0 @@
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Db.Models;
|
||||
|
||||
public class AutoPublishChannel : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
}
|
@@ -5,5 +5,4 @@ public class BanTemplate : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public string Text { get; set; }
|
||||
public int? PruneDays { get; set; }
|
||||
}
|
@@ -17,6 +17,8 @@ public class DiscordUser : DbEntity
|
||||
public bool IsClubAdmin { get; set; }
|
||||
|
||||
public long TotalXp { get; set; }
|
||||
public DateTime LastLevelUp { get; set; } = DateTime.UtcNow;
|
||||
public DateTime LastXpGain { get; set; } = DateTime.MinValue;
|
||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||
|
||||
public long CurrencyAmount { get; set; }
|
||||
|
@@ -24,7 +24,6 @@ public class ShopEntry : DbEntity, IIndexed
|
||||
|
||||
//list
|
||||
public HashSet<ShopEntryItem> Items { get; set; } = new();
|
||||
public ulong? RoleRequirement { get; set; }
|
||||
}
|
||||
|
||||
public class ShopEntryItem : DbEntity
|
||||
|
@@ -8,6 +8,7 @@ public class UserXpStats : DbEntity
|
||||
public long Xp { get; set; }
|
||||
public long AwardedXp { get; set; }
|
||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||
public DateTime LastLevelUp { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public enum XpNotificationLocation { None, Dm, Channel }
|
@@ -13,6 +13,6 @@ public class XpShopOwnedItem : DbEntity
|
||||
|
||||
public enum XpShopItemType
|
||||
{
|
||||
Background = 0,
|
||||
Frame = 1,
|
||||
Background,
|
||||
Frame,
|
||||
}
|
@@ -10,6 +10,10 @@ public sealed class MysqlContext : NadekoContext
|
||||
|
||||
protected override string CurrencyTransactionOtherIdDefaultValue
|
||||
=> "NULL";
|
||||
protected override string DiscordUserLastXpGainDefaultValue
|
||||
=> "(UTC_TIMESTAMP - INTERVAL 1 year)";
|
||||
protected override string LastLevelUpDefaultValue
|
||||
=> "(UTC_TIMESTAMP)";
|
||||
|
||||
public MysqlContext(string connStr = "Server=localhost", string version = "8.0")
|
||||
{
|
||||
|
@@ -65,6 +65,8 @@ public abstract class NadekoContext : DbContext
|
||||
#region Mandatory Provider-Specific Values
|
||||
|
||||
protected abstract string CurrencyTransactionOtherIdDefaultValue { get; }
|
||||
protected abstract string DiscordUserLastXpGainDefaultValue { get; }
|
||||
protected abstract string LastLevelUpDefaultValue { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -164,6 +166,12 @@ public abstract class NadekoContext : DbContext
|
||||
du.Property(x => x.NotifyOnLevelUp)
|
||||
.HasDefaultValue(XpNotificationLocation.None);
|
||||
|
||||
du.Property(x => x.LastXpGain)
|
||||
.HasDefaultValueSql(DiscordUserLastXpGainDefaultValue);
|
||||
|
||||
du.Property(x => x.LastLevelUp)
|
||||
.HasDefaultValueSql(LastLevelUpDefaultValue);
|
||||
|
||||
du.Property(x => x.TotalXp)
|
||||
.HasDefaultValue(0);
|
||||
|
||||
@@ -205,6 +213,9 @@ public abstract class NadekoContext : DbContext
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
xps.Property(x => x.LastLevelUp)
|
||||
.HasDefaultValueSql(LastLevelUpDefaultValue);
|
||||
|
||||
xps.HasIndex(x => x.UserId);
|
||||
xps.HasIndex(x => x.GuildId);
|
||||
xps.HasIndex(x => x.Xp);
|
||||
@@ -330,10 +341,6 @@ public abstract class NadekoContext : DbContext
|
||||
#region BanTemplate
|
||||
|
||||
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
|
||||
modelBuilder.Entity<BanTemplate>()
|
||||
.Property(x => x.PruneDays)
|
||||
.HasDefaultValue(null)
|
||||
.IsRequired(false);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -464,14 +471,6 @@ public abstract class NadekoContext : DbContext
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
#region AutoPublish
|
||||
|
||||
modelBuilder.Entity<AutoPublishChannel>(apc => apc
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
@@ -8,6 +8,10 @@ public sealed class PostgreSqlContext : NadekoContext
|
||||
|
||||
protected override string CurrencyTransactionOtherIdDefaultValue
|
||||
=> "NULL";
|
||||
protected override string DiscordUserLastXpGainDefaultValue
|
||||
=> "timezone('utc', now()) - interval '-1 year'";
|
||||
protected override string LastLevelUpDefaultValue
|
||||
=> "timezone('utc', now())";
|
||||
|
||||
public PostgreSqlContext(string connStr = "Host=localhost")
|
||||
{
|
||||
|
@@ -9,6 +9,10 @@ public sealed class SqliteContext : NadekoContext
|
||||
|
||||
protected override string CurrencyTransactionOtherIdDefaultValue
|
||||
=> "NULL";
|
||||
protected override string DiscordUserLastXpGainDefaultValue
|
||||
=> "datetime('now', '-1 years')";
|
||||
protected override string LastLevelUpDefaultValue
|
||||
=> "datetime('now')";
|
||||
|
||||
public SqliteContext(string connectionString = "Data Source=data/NadekoBot.db", int commandTimeout = 60)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.Mysql
|
||||
{
|
||||
public partial class removeobsoletexpcolumns : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "lastlevelup",
|
||||
table: "userxpstats");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "lastlevelup",
|
||||
table: "discorduser");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "lastxpgain",
|
||||
table: "discorduser");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "lastlevelup",
|
||||
table: "userxpstats",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValueSql: "(UTC_TIMESTAMP)");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "lastlevelup",
|
||||
table: "discorduser",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValueSql: "(UTC_TIMESTAMP)");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "lastxpgain",
|
||||
table: "discorduser",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValueSql: "(UTC_TIMESTAMP - INTERVAL 1 year)");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.Mysql
|
||||
{
|
||||
public partial class banprune : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "prunedays",
|
||||
table: "bantemplates",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "prunedays",
|
||||
table: "bantemplates");
|
||||
}
|
||||
}
|
||||
}
|
@@ -168,6 +168,18 @@ namespace NadekoBot.Migrations.Mysql
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnName("isclubadmin");
|
||||
|
||||
b.Property<DateTime>("LastLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("lastlevelup")
|
||||
.HasDefaultValueSql("(UTC_TIMESTAMP)");
|
||||
|
||||
b.Property<DateTime>("LastXpGain")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("lastxpgain")
|
||||
.HasDefaultValueSql("(UTC_TIMESTAMP - INTERVAL 1 year)");
|
||||
|
||||
b.Property<int>("NotifyOnLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
@@ -675,10 +687,6 @@ namespace NadekoBot.Migrations.Mysql
|
||||
.HasColumnType("bigint unsigned")
|
||||
.HasColumnName("guildid");
|
||||
|
||||
b.Property<int?>("PruneDays")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("prunedays");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.HasColumnType("longtext")
|
||||
.HasColumnName("text");
|
||||
@@ -2557,6 +2565,12 @@ namespace NadekoBot.Migrations.Mysql
|
||||
.HasColumnType("bigint unsigned")
|
||||
.HasColumnName("guildid");
|
||||
|
||||
b.Property<DateTime>("LastLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("lastlevelup")
|
||||
.HasDefaultValueSql("(UTC_TIMESTAMP)");
|
||||
|
||||
b.Property<int>("NotifyOnLevelUp")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("notifyonlevelup");
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.Mysql
|
||||
{
|
||||
public partial class shoprolereq : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<ulong>(
|
||||
name: "rolerequirement",
|
||||
table: "shopentry",
|
||||
type: "bigint unsigned",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "rolerequirement",
|
||||
table: "shopentry");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.Mysql
|
||||
{
|
||||
public partial class autopub : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "autopublishchannel",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
guildid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
||||
channelid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_autopublishchannel", x => x.id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_autopublishchannel_guildid",
|
||||
table: "autopublishchannel",
|
||||
column: "guildid",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "autopublishchannel");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.PostgreSql
|
||||
{
|
||||
public partial class shoprolereq : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "rolerequirement",
|
||||
table: "shopentry",
|
||||
type: "numeric(20,0)",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "rolerequirement",
|
||||
table: "shopentry");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.PostgreSql
|
||||
{
|
||||
public partial class autopub : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "rolerequirement",
|
||||
table: "shopentry",
|
||||
type: "numeric(20,0)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "autopublishchannel",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
|
||||
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_autopublishchannel", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_autopublishchannel_guildid",
|
||||
table: "autopublishchannel",
|
||||
column: "guildid",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "autopublishchannel");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "rolerequirement",
|
||||
table: "shopentry");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.PostgreSql
|
||||
{
|
||||
public partial class banprune : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "prunedays",
|
||||
table: "bantemplates",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "prunedays",
|
||||
table: "bantemplates");
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,7 +36,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("balance");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("UserId")
|
||||
@@ -101,7 +101,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("Description")
|
||||
@@ -163,7 +163,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("currencyamount");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("Discriminator")
|
||||
@@ -176,6 +176,18 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnName("isclubadmin");
|
||||
|
||||
b.Property<DateTime>("LastLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("lastlevelup")
|
||||
.HasDefaultValueSql("timezone('utc', now())");
|
||||
|
||||
b.Property<DateTime>("LastXpGain")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("lastxpgain")
|
||||
.HasDefaultValueSql("timezone('utc', now()) - interval '-1 year'");
|
||||
|
||||
b.Property<int>("NotifyOnLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
@@ -231,7 +243,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -310,7 +322,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("amountcents");
|
||||
|
||||
b.Property<DateTime>("LastCharge")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("lastcharge");
|
||||
|
||||
b.Property<string>("UniquePlatformUserId")
|
||||
@@ -318,7 +330,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("uniqueplatformuserid");
|
||||
|
||||
b.Property<DateTime>("ValidThru")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("validthru");
|
||||
|
||||
b.HasKey("UserId")
|
||||
@@ -345,7 +357,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("MessageId")
|
||||
@@ -376,7 +388,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<bool>("IsUsing")
|
||||
@@ -459,7 +471,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("action");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("GuildConfigId")
|
||||
@@ -506,7 +518,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.HasKey("Id")
|
||||
@@ -532,7 +544,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("action");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("GuildConfigId")
|
||||
@@ -583,7 +595,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("commandtext");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal?>("GuildId")
|
||||
@@ -630,7 +642,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -664,7 +676,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("Source")
|
||||
@@ -698,17 +710,13 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
.HasColumnType("numeric(20,0)")
|
||||
.HasColumnName("guildid");
|
||||
|
||||
b.Property<int?>("PruneDays")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("prunedays");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("text");
|
||||
@@ -733,7 +741,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("ItemId")
|
||||
@@ -760,7 +768,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -798,7 +806,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("commandname");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -832,7 +840,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("amount");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("Extra")
|
||||
@@ -882,7 +890,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -916,7 +924,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("command");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal?>("GuildId")
|
||||
@@ -947,7 +955,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("ItemId")
|
||||
@@ -985,7 +993,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("GuildConfigId")
|
||||
@@ -1020,7 +1028,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -1046,7 +1054,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -1080,7 +1088,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -1110,7 +1118,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -1140,7 +1148,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -1166,7 +1174,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("GuildConfigId")
|
||||
@@ -1245,7 +1253,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("cleverbotenabled");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<bool>("DeleteMessageOnCommand")
|
||||
@@ -1373,7 +1381,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("ItemType")
|
||||
@@ -1412,7 +1420,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("LogSettingId")
|
||||
@@ -1442,7 +1450,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -1485,7 +1493,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelupdatedid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -1621,7 +1629,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("authorid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("Name")
|
||||
@@ -1644,7 +1652,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -1686,7 +1694,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("containsanywhere");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<bool>("DmResponse")
|
||||
@@ -1725,7 +1733,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -1755,7 +1763,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -1817,7 +1825,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -1859,7 +1867,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("MusicPlaylistId")
|
||||
@@ -1909,7 +1917,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -1940,7 +1948,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("Index")
|
||||
@@ -1974,7 +1982,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("PollId")
|
||||
@@ -2017,7 +2025,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("authorname");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -2060,7 +2068,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("Emote")
|
||||
@@ -2115,7 +2123,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<bool>("IsPrivate")
|
||||
@@ -2135,7 +2143,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("userid");
|
||||
|
||||
b.Property<DateTime>("When")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("when");
|
||||
|
||||
b.HasKey("Id")
|
||||
@@ -2161,7 +2169,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("channelid");
|
||||
|
||||
b.Property<DateTime>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
@@ -2208,11 +2216,11 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("amountrewardedthismonth");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<DateTime>("LastReward")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("lastreward");
|
||||
|
||||
b.Property<string>("PlatformUserId")
|
||||
@@ -2243,7 +2251,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("Status")
|
||||
@@ -2270,7 +2278,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("Group")
|
||||
@@ -2315,7 +2323,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("authorid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2365,7 +2373,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("ShopEntryId")
|
||||
@@ -2395,7 +2403,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2425,7 +2433,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2455,7 +2463,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("StreamRoleSettingsId")
|
||||
@@ -2493,7 +2501,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("addroleid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<bool>("Enabled")
|
||||
@@ -2532,7 +2540,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("StreamRoleSettingsId")
|
||||
@@ -2566,7 +2574,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2574,7 +2582,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("guildconfigid");
|
||||
|
||||
b.Property<DateTime>("UnbanAt")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("unbanat");
|
||||
|
||||
b.Property<decimal>("UserId")
|
||||
@@ -2600,7 +2608,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2608,7 +2616,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("guildconfigid");
|
||||
|
||||
b.Property<DateTime>("UnmuteAt")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("unmuteat");
|
||||
|
||||
b.Property<decimal>("UserId")
|
||||
@@ -2634,7 +2642,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2646,7 +2654,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("roleid");
|
||||
|
||||
b.Property<DateTime>("UnbanAt")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("unbanat");
|
||||
|
||||
b.Property<decimal>("UserId")
|
||||
@@ -2676,13 +2684,19 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("awardedxp");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<decimal>("GuildId")
|
||||
.HasColumnType("numeric(20,0)")
|
||||
.HasColumnName("guildid");
|
||||
|
||||
b.Property<DateTime>("LastLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("lastlevelup")
|
||||
.HasDefaultValueSql("timezone('utc', now())");
|
||||
|
||||
b.Property<int>("NotifyOnLevelUp")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("notifyonlevelup");
|
||||
@@ -2727,7 +2741,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2769,7 +2783,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("claimerid");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<long>("Price")
|
||||
@@ -2809,7 +2823,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<string>("ItemEmoji")
|
||||
@@ -2843,7 +2857,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("NewId")
|
||||
@@ -2887,7 +2901,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<bool>("Forgiven")
|
||||
@@ -2949,7 +2963,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("count");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int?>("GuildConfigId")
|
||||
@@ -2991,7 +3005,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
.HasColumnName("amount");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("Level")
|
||||
@@ -3021,7 +3035,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("Level")
|
||||
@@ -3060,7 +3074,7 @@ namespace NadekoBot.Migrations.PostgreSql
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("dateadded");
|
||||
|
||||
b.Property<int>("GuildConfigId")
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class removeobsoletexpcolumns : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastLevelUp",
|
||||
table: "UserXpStats");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastLevelUp",
|
||||
table: "DiscordUser");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastXpGain",
|
||||
table: "DiscordUser");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "LastLevelUp",
|
||||
table: "UserXpStats",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValueSql: "datetime('now')");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "LastLevelUp",
|
||||
table: "DiscordUser",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValueSql: "datetime('now')");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "LastXpGain",
|
||||
table: "DiscordUser",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValueSql: "datetime('now', '-1 years')");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class banprune : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PruneDays",
|
||||
table: "BanTemplates",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PruneDays",
|
||||
table: "BanTemplates");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class shoprolereq : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<ulong>(
|
||||
name: "RoleRequirement",
|
||||
table: "ShopEntry",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RoleRequirement",
|
||||
table: "ShopEntry");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class autopub : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AutoPublishChannel",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AutoPublishChannel", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AutoPublishChannel_GuildId",
|
||||
table: "AutoPublishChannel",
|
||||
column: "GuildId",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AutoPublishChannel");
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,29 +17,6 @@ namespace NadekoBot.Migrations
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "6.0.7");
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Db.Models.AutoPublishChannel", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong>("ChannelId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime?>("DateAdded")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<ulong>("GuildId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GuildId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("AutoPublishChannel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Db.Models.BankUser", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -157,6 +134,16 @@ namespace NadekoBot.Migrations
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(false);
|
||||
|
||||
b.Property<DateTime>("LastLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasDefaultValueSql("datetime('now')");
|
||||
|
||||
b.Property<DateTime>("LastXpGain")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasDefaultValueSql("datetime('now', '-1 years')");
|
||||
|
||||
b.Property<int>("NotifyOnLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
@@ -552,9 +539,6 @@ namespace NadekoBot.Migrations
|
||||
b.Property<ulong>("GuildId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("PruneDays")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@@ -1768,9 +1752,6 @@ namespace NadekoBot.Migrations
|
||||
b.Property<string>("RoleName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<ulong?>("RoleRequirement")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -2022,6 +2003,11 @@ namespace NadekoBot.Migrations
|
||||
b.Property<ulong>("GuildId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("LastLevelUp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasDefaultValueSql("datetime('now')");
|
||||
|
||||
b.Property<int>("NotifyOnLevelUp")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
@@ -33,13 +33,9 @@ public partial class Administration : NadekoModule<AdministrationService>
|
||||
}
|
||||
|
||||
private readonly SomethingOnlyChannelService _somethingOnly;
|
||||
private readonly AutoPublishService _autoPubService;
|
||||
|
||||
public Administration(SomethingOnlyChannelService somethingOnly, AutoPublishService autoPubService)
|
||||
{
|
||||
_somethingOnly = somethingOnly;
|
||||
_autoPubService = autoPubService;
|
||||
}
|
||||
public Administration(SomethingOnlyChannelService somethingOnly)
|
||||
=> _somethingOnly = somethingOnly;
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
@@ -348,58 +344,4 @@ public partial class Administration : NadekoModule<AdministrationService>
|
||||
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[BotPerm(ChannelPermission.CreatePublicThreads)]
|
||||
[UserPerm(ChannelPermission.CreatePublicThreads)]
|
||||
public async Task ThreadCreate([Leftover] string name)
|
||||
{
|
||||
if (ctx.Channel is not SocketTextChannel stc)
|
||||
return;
|
||||
|
||||
await stc.CreateThreadAsync(name, message: ctx.Message.ReferencedMessage);
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[BotPerm(ChannelPermission.ManageThreads)]
|
||||
[UserPerm(ChannelPermission.ManageThreads)]
|
||||
public async Task ThreadDelete([Leftover] string name)
|
||||
{
|
||||
if (ctx.Channel is not SocketTextChannel stc)
|
||||
return;
|
||||
|
||||
var t = stc.Threads.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
if (t is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_found);
|
||||
return;
|
||||
}
|
||||
|
||||
await t.DeleteAsync();
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(ChannelPerm.ManageMessages)]
|
||||
public async Task AutoPublish()
|
||||
{
|
||||
if (ctx.Channel.GetChannelType() != ChannelType.News)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.req_announcement_channel);
|
||||
return;
|
||||
}
|
||||
|
||||
var newState = await _autoPubService.ToggleAutoPublish(ctx.Guild.Id, ctx.Channel.Id);
|
||||
|
||||
if (newState)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.autopublish_enable);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.autopublish_disable);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Nadeko.Common;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
|
@@ -1,87 +0,0 @@
|
||||
#nullable disable
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Db.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Administration.Services;
|
||||
|
||||
public class AutoPublishService : IExecNoCommand, IReadyExecutor, INService
|
||||
{
|
||||
private readonly DbService _db;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IBotCredsProvider _creds;
|
||||
private ConcurrentDictionary<ulong, ulong> _enabled;
|
||||
|
||||
public AutoPublishService(DbService db, DiscordSocketClient client, IBotCredsProvider creds)
|
||||
{
|
||||
_db = db;
|
||||
_client = client;
|
||||
_creds = creds;
|
||||
}
|
||||
|
||||
public async Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg)
|
||||
{
|
||||
if (guild is null)
|
||||
return;
|
||||
|
||||
if (msg.Channel.GetChannelType() != ChannelType.News)
|
||||
return;
|
||||
|
||||
if (!_enabled.TryGetValue(guild.Id, out var cid) || cid != msg.Channel.Id)
|
||||
return;
|
||||
|
||||
await msg.CrosspostAsync(new RequestOptions()
|
||||
{
|
||||
RetryMode = RetryMode.AlwaysFail
|
||||
});
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
var creds = _creds.GetCreds();
|
||||
|
||||
await using var ctx = _db.GetDbContext();
|
||||
var items = await ctx.GetTable<AutoPublishChannel>()
|
||||
.Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId, creds.TotalShards, _client.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
_enabled = items
|
||||
.ToDictionary(x => x.GuildId, x => x.ChannelId)
|
||||
.ToConcurrent();
|
||||
}
|
||||
|
||||
public async Task<bool> ToggleAutoPublish(ulong guildId, ulong channelId)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
var deleted = await ctx.GetTable<AutoPublishChannel>()
|
||||
.DeleteAsync(x => x.GuildId == guildId && x.ChannelId == channelId);
|
||||
|
||||
if (deleted != 0)
|
||||
{
|
||||
_enabled.TryRemove(guildId, out _);
|
||||
return false;
|
||||
}
|
||||
|
||||
await ctx.GetTable<AutoPublishChannel>()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
ChannelId = channelId,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
},
|
||||
old => new()
|
||||
{
|
||||
ChannelId = channelId,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
|
||||
_enabled[guildId] = channelId;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -358,10 +358,9 @@ public class MuteService : INService
|
||||
IGuild guild,
|
||||
IUser user,
|
||||
TimeSpan after,
|
||||
string reason,
|
||||
int pruneDays)
|
||||
string reason)
|
||||
{
|
||||
await guild.AddBanAsync(user.Id, pruneDays, reason);
|
||||
await guild.AddBanAsync(user.Id, 0, reason);
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(guild.Id, set => set.Include(x => x.UnbanTimer));
|
||||
|
@@ -38,14 +38,10 @@ public partial class Administration
|
||||
if (minAgeMinutes < 1 || punishTimeMinutes < 0)
|
||||
return;
|
||||
|
||||
var minutes = (int?)punishTime?.Time.TotalMinutes ?? 0;
|
||||
if (action is PunishmentAction.TimeOut && minutes < 1)
|
||||
minutes = 1;
|
||||
|
||||
await _service.StartAntiAltAsync(ctx.Guild.Id,
|
||||
minAgeMinutes,
|
||||
action,
|
||||
minutes);
|
||||
(int?)punishTime?.Time.TotalMinutes ?? 0);
|
||||
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
@@ -60,9 +56,6 @@ public partial class Administration
|
||||
if (minAgeMinutes < 1)
|
||||
return;
|
||||
|
||||
if (action == PunishmentAction.TimeOut)
|
||||
return;
|
||||
|
||||
await _service.StartAntiAltAsync(ctx.Guild.Id, minAgeMinutes, action, roleId: role.Id);
|
||||
|
||||
await ctx.OkAsync();
|
||||
@@ -130,9 +123,6 @@ public partial class Administration
|
||||
if (time is < 0 or > 60 * 24)
|
||||
return;
|
||||
|
||||
if(action is PunishmentAction.TimeOut && time < 1)
|
||||
return;
|
||||
|
||||
var stats = await _service.StartAntiRaidAsync(ctx.Guild.Id, userThreshold, seconds, action, time);
|
||||
|
||||
if (stats is null)
|
||||
@@ -197,9 +187,6 @@ public partial class Administration
|
||||
if (time is < 0 or > 60 * 24)
|
||||
return;
|
||||
|
||||
if (action is PunishmentAction.TimeOut && time < 1)
|
||||
return;
|
||||
|
||||
var stats = await _service.StartAntiSpamAsync(ctx.Guild.Id, messageCount, action, time, role?.Id);
|
||||
|
||||
await SendConfirmAsync(GetText(strs.prot_enable("Anti-Spam")),
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#nullable disable
|
||||
using CommandLine;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
|
||||
namespace NadekoBot.Modules.Administration;
|
||||
@@ -11,34 +10,17 @@ public partial class Administration
|
||||
{
|
||||
private static readonly TimeSpan _twoWeeks = TimeSpan.FromDays(14);
|
||||
|
||||
public sealed class PruneOptions : INadekoCommandOptions
|
||||
{
|
||||
[Option(shortName: 's', longName: "safe", Default = false, HelpText = "Whether pinned messages should be deleted.", Required = false)]
|
||||
public bool Safe { get; set; }
|
||||
|
||||
[Option(shortName: 'a', longName: "after", Default = null, HelpText = "Prune only messages after the specified message ID.", Required = false)]
|
||||
public ulong? After { get; set; }
|
||||
|
||||
public void NormalizeOptions()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//deletes her own messages, no perm required
|
||||
//delets her own messages, no perm required
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[NadekoOptions(typeof(PruneOptions))]
|
||||
public async Task Prune(params string[] args)
|
||||
public async Task Prune(string parameter = null)
|
||||
{
|
||||
var (opts, _) = OptionsParser.ParseFrom<PruneOptions>(new PruneOptions(), args);
|
||||
|
||||
var user = await ctx.Guild.GetCurrentUserAsync();
|
||||
|
||||
if (opts.Safe)
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, 100, x => x.Author.Id == user.Id && !x.IsPinned, opts.After);
|
||||
if (parameter is "-s" or "--safe")
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, 100, x => x.Author.Id == user.Id && !x.IsPinned);
|
||||
else
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, 100, x => x.Author.Id == user.Id, opts.After);
|
||||
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, 100, x => x.Author.Id == user.Id);
|
||||
ctx.Message.DeleteAfter(3);
|
||||
}
|
||||
|
||||
@@ -47,9 +29,8 @@ public partial class Administration
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(ChannelPerm.ManageMessages)]
|
||||
[BotPerm(ChannelPerm.ManageMessages)]
|
||||
[NadekoOptions(typeof(PruneOptions))]
|
||||
[Priority(1)]
|
||||
public async Task Prune(int count, params string[] args)
|
||||
public async Task Prune(int count, string parameter = null)
|
||||
{
|
||||
count++;
|
||||
if (count < 1)
|
||||
@@ -57,12 +38,10 @@ public partial class Administration
|
||||
if (count > 1000)
|
||||
count = 1000;
|
||||
|
||||
var (opts, _) = OptionsParser.ParseFrom<PruneOptions>(new PruneOptions(), args);
|
||||
|
||||
if (opts.Safe)
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, count, x => !x.IsPinned, opts.After);
|
||||
if (parameter is "-s" or "--safe")
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, count, x => !x.IsPinned);
|
||||
else
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, count, _ => true, opts.After);
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel, count, _ => true);
|
||||
}
|
||||
|
||||
//prune @user [x]
|
||||
@@ -70,19 +49,17 @@ public partial class Administration
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(ChannelPerm.ManageMessages)]
|
||||
[BotPerm(ChannelPerm.ManageMessages)]
|
||||
[NadekoOptions(typeof(PruneOptions))]
|
||||
[Priority(0)]
|
||||
public Task Prune(IGuildUser user, int count = 100, string args = null)
|
||||
=> Prune(user.Id, count, args);
|
||||
public Task Prune(IGuildUser user, int count = 100, string parameter = null)
|
||||
=> Prune(user.Id, count, parameter);
|
||||
|
||||
//prune userid [x]
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(ChannelPerm.ManageMessages)]
|
||||
[BotPerm(ChannelPerm.ManageMessages)]
|
||||
[NadekoOptions(typeof(PruneOptions))]
|
||||
[Priority(0)]
|
||||
public async Task Prune(ulong userId, int count = 100, params string[] args)
|
||||
public async Task Prune(ulong userId, int count = 100, string parameter = null)
|
||||
{
|
||||
if (userId == ctx.User.Id)
|
||||
count++;
|
||||
@@ -93,21 +70,17 @@ public partial class Administration
|
||||
if (count > 1000)
|
||||
count = 1000;
|
||||
|
||||
var (opts, _) = OptionsParser.ParseFrom<PruneOptions>(new PruneOptions(), args);
|
||||
|
||||
if (opts.Safe)
|
||||
if (parameter is "-s" or "--safe")
|
||||
{
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel,
|
||||
count,
|
||||
m => m.Author.Id == userId && DateTime.UtcNow - m.CreatedAt < _twoWeeks && !m.IsPinned,
|
||||
opts.After);
|
||||
m => m.Author.Id == userId && DateTime.UtcNow - m.CreatedAt < _twoWeeks && !m.IsPinned);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _service.PruneWhere((ITextChannel)ctx.Channel,
|
||||
count,
|
||||
m => m.Author.Id == userId && DateTime.UtcNow - m.CreatedAt < _twoWeeks,
|
||||
opts.After);
|
||||
m => m.Author.Id == userId && DateTime.UtcNow - m.CreatedAt < _twoWeeks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,6 @@
|
||||
#nullable disable
|
||||
using Nadeko.Common;
|
||||
|
||||
namespace NadekoBot.Modules.Administration.Services;
|
||||
|
||||
public class PruneService : INService
|
||||
@@ -11,7 +13,7 @@ public class PruneService : INService
|
||||
public PruneService(ILogCommandService logService)
|
||||
=> _logService = logService;
|
||||
|
||||
public async Task PruneWhere(ITextChannel channel, int amount, Func<IMessage, bool> predicate, ulong? after = null)
|
||||
public async Task PruneWhere(ITextChannel channel, int amount, Func<IMessage, bool> predicate)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(channel, nameof(channel));
|
||||
|
||||
@@ -26,14 +28,7 @@ public class PruneService : INService
|
||||
var now = DateTime.UtcNow;
|
||||
IMessage[] msgs;
|
||||
IMessage lastMessage = null;
|
||||
var dled = await channel.GetMessagesAsync(50).FlattenAsync();
|
||||
|
||||
msgs = dled
|
||||
.Where(predicate)
|
||||
.Where(x => after is ulong a ? x.Id > a : true)
|
||||
.Take(amount)
|
||||
.ToArray();
|
||||
|
||||
msgs = (await channel.GetMessagesAsync(50).FlattenAsync()).Where(predicate).Take(amount).ToArray();
|
||||
while (amount > 0 && msgs.Any())
|
||||
{
|
||||
lastMessage = msgs[^1];
|
||||
@@ -67,11 +62,8 @@ public class PruneService : INService
|
||||
amount -= 50;
|
||||
if (amount > 0)
|
||||
{
|
||||
dled = await channel.GetMessagesAsync(lastMessage, Direction.Before, 50).FlattenAsync();
|
||||
|
||||
msgs = dled
|
||||
msgs = (await channel.GetMessagesAsync(lastMessage, Direction.Before, 50).FlattenAsync())
|
||||
.Where(predicate)
|
||||
.Where(x => after is ulong a ? x.Id > a : true)
|
||||
.Take(amount)
|
||||
.ToArray();
|
||||
}
|
||||
|
@@ -67,23 +67,15 @@ public partial class Administration
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
[BotPerm(GuildPerm.ManageRoles)]
|
||||
public async Task ReactionRolesList(int page = 1)
|
||||
public async Task ReactionRolesList()
|
||||
{
|
||||
if (--page < 0)
|
||||
return;
|
||||
|
||||
var reros = await _rero.GetReactionRolesAsync(ctx.Guild.Id);
|
||||
|
||||
await ctx.SendPaginatedConfirmAsync(page, curPage =>
|
||||
{
|
||||
var embed = _eb.Create(ctx)
|
||||
.WithOkColor();
|
||||
|
||||
var content = string.Empty;
|
||||
foreach (var g in reros.OrderBy(x => x.Group)
|
||||
.Skip(curPage * 10)
|
||||
.GroupBy(x => x.MessageId)
|
||||
.OrderBy(x => x.Key))
|
||||
foreach (var g in reros.GroupBy(x => x.MessageId).OrderBy(x => x.Key))
|
||||
{
|
||||
var messageId = g.Key;
|
||||
content +=
|
||||
@@ -97,8 +89,7 @@ public partial class Administration
|
||||
|
||||
foreach (var rero in ggs)
|
||||
{
|
||||
content +=
|
||||
$"\t{rero.Emote} -> {(ctx.Guild.GetRole(rero.RoleId)?.Mention ?? "<missing role>")}";
|
||||
content += $"\t{rero.Emote} -> {(ctx.Guild.GetRole(rero.RoleId)?.Mention ?? "<missing role>")}";
|
||||
if (rero.LevelReq > 0)
|
||||
content += $" (lvl {rero.LevelReq}+)";
|
||||
content += '\n';
|
||||
@@ -111,8 +102,7 @@ public partial class Administration
|
||||
? "There are no reaction roles on this server"
|
||||
: content);
|
||||
|
||||
return embed;
|
||||
}, reros.Count, 10);
|
||||
await ctx.Channel.EmbedAsync(embed);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
|
@@ -3,9 +3,6 @@
|
||||
namespace NadekoBot.Modules.Administration;
|
||||
|
||||
public sealed class DummyLogCommandService : ILogCommandService
|
||||
#if GLOBAL_NADEKO
|
||||
, INService
|
||||
#endif
|
||||
{
|
||||
public void AddDeleteIgnore(ulong xId)
|
||||
{
|
||||
|
@@ -345,10 +345,6 @@ public partial class Administration
|
||||
if (punish is PunishmentAction.AddRole or PunishmentAction.Warn)
|
||||
return;
|
||||
|
||||
// you must specify the time for timeout
|
||||
if (punish is PunishmentAction.TimeOut && time is null)
|
||||
return;
|
||||
|
||||
var success = _service.WarnPunish(ctx.Guild.Id, number, punish, time);
|
||||
|
||||
if (!success)
|
||||
@@ -429,8 +425,7 @@ public partial class Administration
|
||||
}
|
||||
}
|
||||
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
await _mute.TimedBan(ctx.Guild, user, time.Time, (ctx.User + " | " + msg).TrimTo(512), banPrune);
|
||||
await _mute.TimedBan(ctx.Guild, user, time.Time, (ctx.User + " | " + msg).TrimTo(512));
|
||||
var toSend = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText(strs.banned_user))
|
||||
@@ -456,8 +451,7 @@ public partial class Administration
|
||||
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
|
||||
if (user is null)
|
||||
{
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
await ctx.Guild.AddBanAsync(userId, banPrune, (ctx.User + " | " + msg).TrimTo(512));
|
||||
await ctx.Guild.AddBanAsync(userId, 7, (ctx.User + " | " + msg).TrimTo(512));
|
||||
|
||||
await ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
@@ -492,8 +486,7 @@ public partial class Administration
|
||||
dmFailed = true;
|
||||
}
|
||||
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
await ctx.Guild.AddBanAsync(user, banPrune, (ctx.User + " | " + msg).TrimTo(512));
|
||||
await ctx.Guild.AddBanAsync(user, 7, (ctx.User + " | " + msg).TrimTo(512));
|
||||
|
||||
var toSend = _eb.Create()
|
||||
.WithOkColor()
|
||||
@@ -507,26 +500,6 @@ public partial class Administration
|
||||
await ctx.Channel.EmbedAsync(toSend);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.BanMembers)]
|
||||
[BotPerm(GuildPerm.BanMembers)]
|
||||
public async Task BanPrune(int days)
|
||||
{
|
||||
if (days < 0 || days > 7)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.invalid_input);
|
||||
return;
|
||||
}
|
||||
|
||||
await _service.SetBanPruneAsync(ctx.Guild.Id, days);
|
||||
|
||||
if (days == 0)
|
||||
await ReplyConfirmLocalizedAsync(strs.ban_prune_disabled);
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.ban_prune(days));
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.BanMembers)]
|
||||
@@ -678,8 +651,7 @@ public partial class Administration
|
||||
dmFailed = true;
|
||||
}
|
||||
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
await ctx.Guild.AddBanAsync(user, banPrune, ("Softban | " + ctx.User + " | " + msg).TrimTo(512));
|
||||
await ctx.Guild.AddBanAsync(user, 7, ("Softban | " + ctx.User + " | " + msg).TrimTo(512));
|
||||
try { await ctx.Guild.RemoveBanAsync(user); }
|
||||
catch { await ctx.Guild.RemoveBanAsync(user); }
|
||||
|
||||
@@ -747,49 +719,6 @@ public partial class Administration
|
||||
await ctx.Channel.EmbedAsync(toSend);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.ModerateMembers)]
|
||||
[BotPerm(GuildPerm.ModerateMembers)]
|
||||
[Priority(2)]
|
||||
public async Task Timeout(IUser globalUser, StoopidTime time, [Leftover] string msg = null)
|
||||
{
|
||||
var user = await ctx.Guild.GetUserAsync(globalUser.Id);
|
||||
|
||||
if (user is null)
|
||||
return;
|
||||
|
||||
if (!await CheckRoleHierarchy(user))
|
||||
return;
|
||||
|
||||
var dmFailed = false;
|
||||
|
||||
try
|
||||
{
|
||||
var dmMessage = GetText(strs.timeoutdm(Format.Bold(ctx.Guild.Name), msg));
|
||||
await user.EmbedAsync(_eb.Create(ctx)
|
||||
.WithPendingColor()
|
||||
.WithDescription(dmMessage));
|
||||
}
|
||||
catch
|
||||
{
|
||||
dmFailed = true;
|
||||
}
|
||||
|
||||
await user.SetTimeOutAsync(time.Time);
|
||||
|
||||
var toSend = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("⏳ " + GetText(strs.timedout_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
|
||||
if (dmFailed)
|
||||
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
|
||||
|
||||
await ctx.Channel.EmbedAsync(toSend);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.BanMembers)]
|
||||
@@ -846,12 +775,11 @@ public partial class Administration
|
||||
|
||||
var banningMessage = await ctx.Channel.EmbedAsync(toSend);
|
||||
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
foreach (var toBan in banning)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ctx.Guild.AddBanAsync(toBan.Id, banPrune, $"{ctx.User} | Massban");
|
||||
await ctx.Guild.AddBanAsync(toBan.Id, 7, $"{ctx.User} | Massban");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -890,11 +818,10 @@ public partial class Administration
|
||||
.AddField(GetText(strs.invalid(missing)), missStr)
|
||||
.WithPendingColor());
|
||||
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
//do the banning
|
||||
await Task.WhenAll(bans.Where(x => x.Id.HasValue)
|
||||
.Select(x => ctx.Guild.AddBanAsync(x.Id.Value,
|
||||
banPrune,
|
||||
7,
|
||||
x.Reason,
|
||||
new()
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#nullable disable
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Common.TypeReaders.Models;
|
||||
@@ -128,7 +127,6 @@ public class UserPunishService : INService, IReadyExecutor
|
||||
if (!await CheckPermission(guild, p))
|
||||
return;
|
||||
|
||||
int banPrune;
|
||||
switch (p)
|
||||
{
|
||||
case PunishmentAction.Mute:
|
||||
@@ -153,15 +151,13 @@ public class UserPunishService : INService, IReadyExecutor
|
||||
await user.KickAsync(reason);
|
||||
break;
|
||||
case PunishmentAction.Ban:
|
||||
banPrune = await GetBanPruneAsync(user.GuildId) ?? 7;
|
||||
if (minutes == 0)
|
||||
await guild.AddBanAsync(user, reason: reason, pruneDays: banPrune);
|
||||
await guild.AddBanAsync(user, reason: reason, pruneDays: 7);
|
||||
else
|
||||
await _mute.TimedBan(user.Guild, user, TimeSpan.FromMinutes(minutes), reason, banPrune);
|
||||
await _mute.TimedBan(user.Guild, user, TimeSpan.FromMinutes(minutes), reason);
|
||||
break;
|
||||
case PunishmentAction.Softban:
|
||||
banPrune = await GetBanPruneAsync(user.GuildId) ?? 7;
|
||||
await guild.AddBanAsync(user, banPrune, $"Softban | {reason}");
|
||||
await guild.AddBanAsync(user, 7, $"Softban | {reason}");
|
||||
try
|
||||
{
|
||||
await guild.RemoveBanAsync(user);
|
||||
@@ -197,9 +193,6 @@ public class UserPunishService : INService, IReadyExecutor
|
||||
case PunishmentAction.Warn:
|
||||
await Warn(guild, user.Id, mod, 1, reason);
|
||||
break;
|
||||
case PunishmentAction.TimeOut:
|
||||
await user.SetTimeOutAsync(TimeSpan.FromMinutes(minutes));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,8 +224,6 @@ public class UserPunishService : INService, IReadyExecutor
|
||||
return botUser.GuildPermissions.MuteMembers;
|
||||
case PunishmentAction.AddRole:
|
||||
return botUser.GuildPermissions.ManageRoles;
|
||||
case PunishmentAction.TimeOut:
|
||||
return botUser.GuildPermissions.ModerateMembers;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
@@ -360,7 +351,7 @@ public class UserPunishService : INService, IReadyExecutor
|
||||
await uow.Warnings.ForgiveAll(guildId, userId, moderator);
|
||||
else
|
||||
toReturn = uow.Warnings.Forgive(guildId, userId, moderator, index - 1);
|
||||
await uow.SaveChangesAsync();
|
||||
uow.SaveChanges();
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@@ -381,9 +372,6 @@ public class UserPunishService : INService, IReadyExecutor
|
||||
if (punish is PunishmentAction.AddRole && role is null)
|
||||
return false;
|
||||
|
||||
if (punish is PunishmentAction.TimeOut && time is null)
|
||||
return false;
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
var ps = uow.GuildConfigsForId(guildId, set => set.Include(x => x.WarnPunishments)).WarnPunishments;
|
||||
var toDelete = ps.Where(x => x.Count == number);
|
||||
@@ -493,37 +481,6 @@ public class UserPunishService : INService, IReadyExecutor
|
||||
uow.SaveChanges();
|
||||
}
|
||||
|
||||
public async Task SetBanPruneAsync(ulong guildId, int? pruneDays)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
await ctx.BanTemplates
|
||||
.ToLinqToDBTable()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Text = null,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
PruneDays = pruneDays
|
||||
},
|
||||
old => new()
|
||||
{
|
||||
PruneDays = pruneDays
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<int?> GetBanPruneAsync(ulong guildId)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
return await ctx.BanTemplates
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.Select(x => x.PruneDays)
|
||||
.FirstOrDefaultAsyncLinqToDB();
|
||||
}
|
||||
|
||||
public SmartText GetBanUserDmEmbed(
|
||||
ICommandContext context,
|
||||
IGuildUser target,
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#nullable disable
|
||||
|
||||
using Nadeko.Common;
|
||||
|
||||
namespace NadekoBot.Modules.NadekoExpressions;
|
||||
|
||||
[Name("Expressions")]
|
||||
@@ -23,10 +25,15 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
|
||||
=> (ctx.Guild is null && _creds.IsOwner(ctx.User))
|
||||
|| (ctx.Guild is not null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
|
||||
|
||||
private async Task ExprAddInternalAsync(string key, string message)
|
||||
[Cmd]
|
||||
public async Task ExprAdd(string key, [Leftover] string message)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
|
||||
return;
|
||||
|
||||
if (!AdminInGuildOrOwnerInDm())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,43 +48,12 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
|
||||
message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
public async Task ExprAddServer(string key, [Leftover] string message)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await ExprAddInternalAsync(key, message);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
public async Task ExprAdd(string key, [Leftover] string message)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AdminInGuildOrOwnerInDm())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
|
||||
return;
|
||||
}
|
||||
|
||||
await ExprAddInternalAsync(key, message);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
public async Task ExprEdit(kwum id, [Leftover] string message)
|
||||
{
|
||||
var channel = ctx.Channel as ITextChannel;
|
||||
if (string.IsNullOrWhiteSpace(message) || id < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((channel is null && !_creds.IsOwner(ctx.User))
|
||||
|| (channel is not null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
|
||||
@@ -98,19 +74,15 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
|
||||
message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
|
||||
}
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[Priority(1)]
|
||||
public async Task ExprList(int page = 1)
|
||||
{
|
||||
if (--page < 0 || page > 999)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var expressions = _service.GetExpressionsFor(ctx.Guild?.Id);
|
||||
|
||||
@@ -160,8 +132,15 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
|
||||
found.Response.TrimTo(1000).Replace("](", "]\\(")));
|
||||
}
|
||||
|
||||
public async Task ExprDeleteInternalAsync(kwum id)
|
||||
[Cmd]
|
||||
public async Task ExprDelete(kwum id)
|
||||
{
|
||||
if (!AdminInGuildOrOwnerInDm())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
|
||||
return;
|
||||
}
|
||||
|
||||
var ex = await _service.DeleteAsync(ctx.Guild?.Id, id);
|
||||
|
||||
if (ex is not null)
|
||||
@@ -174,28 +153,8 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
|
||||
.AddField(GetText(strs.response), ex.Response.TrimTo(1024)));
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
|
||||
}
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ExprDeleteServer(kwum id)
|
||||
=> await ExprDeleteInternalAsync(id);
|
||||
|
||||
[Cmd]
|
||||
public async Task ExprDelete(kwum id)
|
||||
{
|
||||
if (!AdminInGuildOrOwnerInDm())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
|
||||
return;
|
||||
}
|
||||
|
||||
await ExprDeleteInternalAsync(id);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
public async Task ExprReact(kwum id, params string[] emojiStrs)
|
||||
@@ -233,10 +192,8 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
|
||||
succ.Add(emojiStr);
|
||||
|
||||
if (succ.Count >= 3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
@@ -11,14 +11,10 @@ public partial class Gambling
|
||||
public partial class BankCommands : GamblingModule<IBankService>
|
||||
{
|
||||
private readonly IBankService _bank;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public BankCommands(GamblingConfigService gcs,
|
||||
IBankService bank,
|
||||
DiscordSocketClient client) : base(gcs)
|
||||
public BankCommands(GamblingConfigService gcs, IBankService bank) : base(gcs)
|
||||
{
|
||||
_bank = bank;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -72,50 +68,5 @@ public partial class Gambling
|
||||
await ReplyErrorLocalizedAsync(strs.cant_dm);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task BankTakeInternalAsync(long amount, ulong userId)
|
||||
{
|
||||
if (await _bank.TakeAsync(userId, amount))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.take_fail(N(amount),
|
||||
_client.GetUser(userId)?.ToString()
|
||||
?? userId.ToString(),
|
||||
CurrencySign));
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
private async Task BankAwardInternalAsync(long amount, ulong userId)
|
||||
{
|
||||
if (await _bank.AwardAsync(userId, amount))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.take_fail(N(amount),
|
||||
_client.GetUser(userId)?.ToString()
|
||||
?? userId.ToString(),
|
||||
CurrencySign));
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
[Priority(1)]
|
||||
public async Task BankTake(long amount, [Leftover] IUser user)
|
||||
=> await BankTakeInternalAsync(amount, user.Id);
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
[Priority(0)]
|
||||
public async Task BankTake(long amount, ulong userId)
|
||||
=> await BankTakeInternalAsync(amount, userId);
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
public async Task BankAward(long amount, [Leftover] IUser user)
|
||||
=> await BankAwardInternalAsync(amount, user.Id);
|
||||
}
|
||||
}
|
@@ -15,48 +15,6 @@ public sealed class BankService : IBankService, INService
|
||||
_db = db;
|
||||
}
|
||||
|
||||
public async Task<bool> AwardAsync(ulong userId, long amount)
|
||||
{
|
||||
if (amount <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(amount));
|
||||
|
||||
await using var ctx = _db.GetDbContext();
|
||||
await ctx.BankUsers
|
||||
.ToLinqToDBTable()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
UserId = userId,
|
||||
Balance = amount
|
||||
},
|
||||
(old) => new()
|
||||
{
|
||||
Balance = old.Balance + amount
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
UserId = userId
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> TakeAsync(ulong userId, long amount)
|
||||
{
|
||||
if (amount <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(amount));
|
||||
|
||||
await using var ctx = _db.GetDbContext();
|
||||
var rows = await ctx.BankUsers
|
||||
.ToLinqToDBTable()
|
||||
.Where(x => x.UserId == userId && x.Balance >= amount)
|
||||
.UpdateAsync((old) => new()
|
||||
{
|
||||
Balance = old.Balance - amount
|
||||
});
|
||||
|
||||
return rows > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> DepositAsync(ulong userId, long amount)
|
||||
{
|
||||
if (amount <= 0)
|
||||
|
@@ -5,6 +5,4 @@ public interface IBankService
|
||||
Task<bool> DepositAsync(ulong userId, long amount);
|
||||
Task<bool> WithdrawAsync(ulong userId, long amount);
|
||||
Task<long> GetBalanceAsync(ulong userId);
|
||||
Task<bool> AwardAsync(ulong userId, long amount);
|
||||
Task<bool> TakeAsync(ulong userId, long amount);
|
||||
}
|
13
src/NadekoBot/Modules/Gambling/CashInteraction.cs
Normal file
13
src/NadekoBot/Modules/Gambling/CashInteraction.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#nullable disable
|
||||
namespace NadekoBot.Modules.Gambling;
|
||||
|
||||
public class CashInteraction : NInteraction
|
||||
{
|
||||
protected override NadekoInteractionData Data
|
||||
=> new NadekoInteractionData(new Emoji("🏦"), "cash:bank_show_balance");
|
||||
|
||||
public CashInteraction(DiscordSocketClient client, ulong userId, Func<SocketMessageComponent, Task> action)
|
||||
: base(client, userId, action)
|
||||
{
|
||||
}
|
||||
}
|
@@ -145,9 +145,6 @@ public partial class Gambling
|
||||
|
||||
public async Task BetDrawInternal(long amount, InputValueGuess? val, InputColorGuess? col)
|
||||
{
|
||||
if (amount <= 0)
|
||||
return;
|
||||
|
||||
var res = await _service.BetDrawAsync(ctx.User.Id,
|
||||
amount,
|
||||
(byte?)val,
|
||||
|
@@ -99,7 +99,26 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
PrettyName = "Timely"
|
||||
};
|
||||
|
||||
private async Task RemindTimelyAction(SocketMessageComponent smc, DateTime when)
|
||||
public class RemindMeInteraction : NInteraction
|
||||
{
|
||||
public RemindMeInteraction(
|
||||
[NotNull] DiscordSocketClient client,
|
||||
ulong userId,
|
||||
[NotNull] Func<SocketMessageComponent, Task> action)
|
||||
: base(client, userId, action)
|
||||
{
|
||||
}
|
||||
|
||||
protected override NadekoInteractionData Data
|
||||
=> new NadekoInteractionData(
|
||||
Emote: Emoji.Parse("⏰"),
|
||||
CustomId: "timely:remind_me",
|
||||
Text: "Remind me"
|
||||
);
|
||||
}
|
||||
|
||||
private Func<SocketMessageComponent, Task> RemindTimelyAction(DateTime when)
|
||||
=> async smc =>
|
||||
{
|
||||
var tt = TimestampTag.FromDateTime(when, TimestampTagStyles.Relative);
|
||||
|
||||
@@ -111,7 +130,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
GetText(strs.timely_time));
|
||||
|
||||
await smc.RespondConfirmAsync(_eb, GetText(strs.remind_timely(tt)), ephemeral: true);
|
||||
}
|
||||
};
|
||||
|
||||
[Cmd]
|
||||
public async Task Timely()
|
||||
@@ -128,7 +147,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
var relativeTag = TimestampTag.FromDateTime(now.Add(rem), TimestampTagStyles.Relative);
|
||||
await ReplyPendingLocalizedAsync(strs.timely_already_claimed(relativeTag));
|
||||
await ReplyErrorLocalizedAsync(strs.timely_already_claimed(relativeTag));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,17 +157,11 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
|
||||
await _cs.AddAsync(ctx.User.Id, val, new("timely", "claim"));
|
||||
|
||||
var inter = _inter
|
||||
.Create(ctx.User.Id,
|
||||
new SimpleInteraction<DateTime>(
|
||||
new ButtonBuilder(
|
||||
label: "Remind me",
|
||||
emote: Emoji.Parse("⏰"),
|
||||
customId: "timely:remind_me"),
|
||||
RemindTimelyAction,
|
||||
DateTime.UtcNow.Add(TimeSpan.FromHours(period))));
|
||||
var inter = new RemindMeInteraction(_client,
|
||||
ctx.User.Id,
|
||||
RemindTimelyAction(DateTime.UtcNow.Add(TimeSpan.FromHours(period))));
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.timely(N(val), period), inter);
|
||||
await ReplyConfirmLocalizedAsync(strs.timely(N(val), period), inter.GetInteraction());
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -249,7 +262,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
List<CurrencyTransaction> trs;
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
trs = await uow.CurrencyTransactions.GetPageFor(userId, page);
|
||||
trs = uow.CurrencyTransactions.GetPageFor(userId, page);
|
||||
}
|
||||
|
||||
var embed = _eb.Create()
|
||||
@@ -349,7 +362,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
await ReplyConfirmLocalizedAsync(strs.has(Format.Code(userId.ToString()), cur));
|
||||
}
|
||||
|
||||
private async Task BankAction(SocketMessageComponent smc, object _)
|
||||
private async Task BankAction(SocketMessageComponent smc)
|
||||
{
|
||||
var balance = await _bank.GetBalanceAsync(ctx.User.Id);
|
||||
|
||||
@@ -359,12 +372,8 @@ public partial class Gambling : GamblingModule<GamblingService>
|
||||
.Pipe(text => smc.RespondConfirmAsync(_eb, text, ephemeral: true));
|
||||
}
|
||||
|
||||
private NadekoInteraction CreateCashInteraction()
|
||||
=> _inter.Create<object>(ctx.User.Id,
|
||||
new(new(
|
||||
customId: "cash:bank_show_balance",
|
||||
emote: new Emoji("🏦")),
|
||||
BankAction));
|
||||
private NadekoButtonInteraction CreateCashInteraction()
|
||||
=> new CashInteraction(_client, ctx.User.Id, BankAction).GetInteraction();
|
||||
|
||||
[Cmd]
|
||||
[Priority(1)]
|
||||
|
@@ -78,7 +78,7 @@ public class CurrencyConfig
|
||||
[Comment(@"What is the name of the currency")]
|
||||
public string Name { get; set; } = "Nadeko Flower";
|
||||
|
||||
[Comment(@"For how long (in days) will the transactions be kept in the database (curtrs)
|
||||
[Comment(@"For how long will the transactions be kept in the database (curtrs)
|
||||
Set 0 to disable cleanup (keep transactions forever)")]
|
||||
public int TransactionsLifetime { get; set; } = 0;
|
||||
}
|
||||
|
@@ -38,6 +38,4 @@ public interface IShopService
|
||||
/// <param name="toIndex">Destination index of the entry</param>
|
||||
/// <returns>Whether swap was successful</returns>
|
||||
Task<bool> MoveEntryAsync(ulong guildId, int fromIndex, int toIndex);
|
||||
|
||||
Task<bool> SetItemRoleRequirementAsync(ulong guildId, int index, ulong? roleId);
|
||||
}
|
@@ -98,23 +98,6 @@ public partial class Gambling
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.RoleRequirement is ulong reqRoleId)
|
||||
{
|
||||
var role = ctx.Guild.GetRole(reqRoleId);
|
||||
if (role is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.shop_item_req_role_not_found);
|
||||
return;
|
||||
}
|
||||
|
||||
var guser = (IGuildUser)ctx.User;
|
||||
if (!guser.RoleIds.Contains(reqRoleId))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.shop_item_req_role_unfulfilled(Format.Bold(role.ToString())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.Type == ShopEntryType.Role)
|
||||
{
|
||||
var guser = (IGuildUser)ctx.User;
|
||||
@@ -429,27 +412,6 @@ public partial class Gambling
|
||||
await ctx.ErrorAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
public async Task ShopReq(int itemIndex, [Leftover] IRole role = null)
|
||||
{
|
||||
if (--itemIndex < 0)
|
||||
return;
|
||||
|
||||
var succ = await _service.SetItemRoleRequirementAsync(ctx.Guild.Id, itemIndex, role?.Id);
|
||||
if (!succ)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.shop_item_not_found);
|
||||
return;
|
||||
}
|
||||
|
||||
if (role is null)
|
||||
await ReplyConfirmLocalizedAsync(strs.shop_item_role_no_req(itemIndex));
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.shop_item_role_req(itemIndex + 1, role));
|
||||
}
|
||||
|
||||
public IEmbedBuilder EntryToEmbed(ShopEntry entry)
|
||||
{
|
||||
var embed = _eb.Create().WithOkColor();
|
||||
@@ -481,17 +443,11 @@ public partial class Gambling
|
||||
|
||||
public string EntryToString(ShopEntry entry)
|
||||
{
|
||||
var prepend = string.Empty;
|
||||
if (entry.RoleRequirement is not null)
|
||||
prepend = Format.Italics(GetText(strs.shop_item_requires_role($"<@&{entry.RoleRequirement}>")))
|
||||
+ Environment.NewLine;
|
||||
|
||||
if (entry.Type == ShopEntryType.Role)
|
||||
return prepend
|
||||
+ GetText(strs.shop_role(Format.Bold(ctx.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE")));
|
||||
return GetText(strs.shop_role(Format.Bold(ctx.Guild.GetRole(entry.RoleId)?.Name ?? "MISSING_ROLE")));
|
||||
if (entry.Type == ShopEntryType.List)
|
||||
return prepend + GetText(strs.unique_items_left(entry.Items.Count)) + "\n" + entry.Name;
|
||||
return prepend;
|
||||
return GetText(strs.unique_items_left(entry.Items.Count)) + "\n" + entry.Name;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
@@ -94,20 +94,4 @@ public class ShopService : IShopService, INService
|
||||
await uow.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> SetItemRoleRequirementAsync(ulong guildId, int index, ulong? roleId)
|
||||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
var entries = GetEntriesInternal(uow, guildId);
|
||||
|
||||
if (index >= entries.Count)
|
||||
return false;
|
||||
|
||||
var entry = entries[index];
|
||||
|
||||
entry.RoleRequirement = roleId;
|
||||
|
||||
await uow.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -27,6 +27,12 @@ public partial class Gambling
|
||||
private static decimal totalBet;
|
||||
private static decimal totalPaidOut;
|
||||
|
||||
private static readonly ConcurrentHashSet<ulong> _runningUsers = new();
|
||||
|
||||
//here is a payout chart
|
||||
//https://lh6.googleusercontent.com/-i1hjAJy_kN4/UswKxmhrbPI/AAAAAAAAB1U/82wq_4ZZc-Y/DE6B0895-6FC1-48BE-AC4F-14D1B91AB75B.jpg
|
||||
//thanks to judge for helping me with this
|
||||
|
||||
private readonly IImageCache _images;
|
||||
private readonly FontProvider _fonts;
|
||||
private readonly DbService _db;
|
||||
@@ -67,6 +73,16 @@ public partial class Gambling
|
||||
|
||||
await ctx.Channel.EmbedAsync(embed);
|
||||
}
|
||||
public sealed class SlotInteraction : NInteraction
|
||||
{
|
||||
public SlotInteraction(DiscordSocketClient client, ulong userId, Func<SocketMessageComponent, Task> action) : base(client, userId, action)
|
||||
{
|
||||
}
|
||||
|
||||
protected override NadekoInteractionData Data { get; } = new(Emoji.Parse("🔁"),
|
||||
"slot:again",
|
||||
"Pull Again");
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
public async Task Slot(ShmartNumber amount)
|
||||
@@ -78,13 +94,18 @@ public partial class Gambling
|
||||
|
||||
await ctx.Channel.TriggerTypingAsync();
|
||||
|
||||
if (!_runningUsers.Add(ctx.User.Id))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (await InternalSlotAsync(amount) is not SlotResult result)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign));
|
||||
return;
|
||||
}
|
||||
|
||||
var text = GetSlotMessageTextInternal(result);
|
||||
var msg = GetSlotMessageInternal(result);
|
||||
|
||||
using var image = await GenerateSlotImageAsync(amount, result);
|
||||
await using var imgStream = await image.ToStreamAsync();
|
||||
@@ -92,20 +113,24 @@ public partial class Gambling
|
||||
|
||||
var eb = _eb.Create(ctx)
|
||||
.WithAuthor(ctx.User)
|
||||
.WithDescription(Format.Bold(text))
|
||||
.WithDescription(Format.Bold(msg))
|
||||
.WithImageUrl($"attachment://result.png")
|
||||
.WithOkColor();
|
||||
|
||||
var bb = new ButtonBuilder(emote: Emoji.Parse("🔁"), customId: "slot:again", label: "Pull Again");
|
||||
var si = new SimpleInteraction<ShmartNumber>(bb, (_, amount) => Slot(amount), amount);
|
||||
|
||||
var inter = _inter.Create(ctx.User.Id, si);
|
||||
var msg = await ctx.Channel.SendFileAsync(imgStream,
|
||||
// var inter = slotInteraction.GetInteraction();
|
||||
await ctx.Channel.SendFileAsync(imgStream,
|
||||
"result.png",
|
||||
embed: eb.Build(),
|
||||
components: inter.CreateComponent()
|
||||
embed: eb.Build()
|
||||
// components: inter.CreateComponent()
|
||||
);
|
||||
await inter.RunAsync(msg);
|
||||
|
||||
// await inter.RunAsync(resMsg);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
_runningUsers.TryRemove(ctx.User.Id);
|
||||
}
|
||||
}
|
||||
|
||||
// private SlotInteraction CreateSlotInteractionIntenal(long amount)
|
||||
@@ -156,7 +181,7 @@ public partial class Gambling
|
||||
// });
|
||||
// }
|
||||
|
||||
private string GetSlotMessageTextInternal(SlotResult result)
|
||||
private string GetSlotMessageInternal(SlotResult result)
|
||||
{
|
||||
var multi = result.Multiplier.ToString("0.##");
|
||||
var msg = result.WinType switch
|
||||
@@ -176,6 +201,7 @@ public partial class Gambling
|
||||
|
||||
if (!maybeResult.TryPickT0(out var result, out var error))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -112,25 +112,25 @@ public partial class Games
|
||||
|
||||
private void RegisterEvents(TriviaGame trivia)
|
||||
{
|
||||
trivia.OnQuestion += OnTriviaQuestion;
|
||||
trivia.OnHint += OnTriviaHint;
|
||||
trivia.OnGuess += OnTriviaGuess;
|
||||
trivia.OnEnded += OnTriviaEnded;
|
||||
trivia.OnStats += OnTriviaStats;
|
||||
trivia.OnTimeout += OnTriviaTimeout;
|
||||
trivia.OnQuestion += OnTriviaOnOnQuestion;
|
||||
trivia.OnHint += OnTriviaOnOnHint;
|
||||
trivia.OnGuess += OnTriviaOnOnGuess;
|
||||
trivia.OnEnded += OnTriviaOnOnEnded;
|
||||
trivia.OnStats += OnTriviaOnOnStats;
|
||||
trivia.OnTimeout += OnTriviaOnOnTimeout;
|
||||
}
|
||||
|
||||
private void UnregisterEvents(TriviaGame trivia)
|
||||
{
|
||||
trivia.OnQuestion -= OnTriviaQuestion;
|
||||
trivia.OnHint -= OnTriviaHint;
|
||||
trivia.OnGuess -= OnTriviaGuess;
|
||||
trivia.OnEnded -= OnTriviaEnded;
|
||||
trivia.OnStats -= OnTriviaStats;
|
||||
trivia.OnTimeout -= OnTriviaTimeout;
|
||||
trivia.OnQuestion -= OnTriviaOnOnQuestion;
|
||||
trivia.OnHint -= OnTriviaOnOnHint;
|
||||
trivia.OnGuess -= OnTriviaOnOnGuess;
|
||||
trivia.OnEnded -= OnTriviaOnOnEnded;
|
||||
trivia.OnStats -= OnTriviaOnOnStats;
|
||||
trivia.OnTimeout -= OnTriviaOnOnTimeout;
|
||||
}
|
||||
|
||||
private async Task OnTriviaHint(TriviaGame game, TriviaQuestion question)
|
||||
private async Task OnTriviaOnOnHint(TriviaGame game, TriviaQuestion question)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -150,11 +150,11 @@ public partial class Games
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "Error editing trivia message");
|
||||
Log.Warning(ex, "Error editing triva message");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnTriviaQuestion(TriviaGame game, TriviaQuestion question)
|
||||
private async Task OnTriviaOnOnQuestion(TriviaGame game, TriviaQuestion question)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -173,16 +173,19 @@ public partial class Games
|
||||
|
||||
questionMessage = await ctx.Channel.EmbedAsync(questionEmbed);
|
||||
}
|
||||
catch (HttpException ex) when (ex.HttpCode is HttpStatusCode.NotFound or HttpStatusCode.Forbidden
|
||||
or HttpStatusCode.BadRequest)
|
||||
catch (HttpException ex) when (ex.HttpCode is HttpStatusCode.NotFound or HttpStatusCode.Forbidden or HttpStatusCode.BadRequest)
|
||||
{
|
||||
Log.Warning("Unable to send trivia questions. Stopping immediately");
|
||||
game.Stop();
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "Error sending trivia embed");
|
||||
await Task.Delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnTriviaTimeout(TriviaGame _, TriviaQuestion question)
|
||||
private async Task OnTriviaOnOnTimeout(TriviaGame _, TriviaQuestion question)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -202,7 +205,7 @@ public partial class Games
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnTriviaStats(TriviaGame game)
|
||||
private async Task OnTriviaOnOnStats(TriviaGame game)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -214,7 +217,7 @@ public partial class Games
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnTriviaEnded(TriviaGame game)
|
||||
private async Task OnTriviaOnOnEnded(TriviaGame game)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -234,9 +237,10 @@ public partial class Games
|
||||
}
|
||||
|
||||
UnregisterEvents(game);
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
private async Task OnTriviaGuess(TriviaGame _, TriviaUser user, TriviaQuestion question, bool isWin)
|
||||
private async Task OnTriviaOnOnGuess(TriviaGame _, TriviaUser user, TriviaQuestion question, bool isWin)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System.Threading.Channels;
|
||||
using Exception = System.Exception;
|
||||
|
||||
namespace NadekoBot.Modules.Games.Common.Trivia;
|
||||
|
||||
@@ -65,6 +64,7 @@ public sealed class TriviaGame
|
||||
if (errorCount >= 5)
|
||||
{
|
||||
Log.Warning("Trivia errored 5 times and will quit");
|
||||
await OnEnded(this);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public sealed class TriviaGame
|
||||
|
||||
var maybeQuestion = await _questionPool.GetQuestionAsync();
|
||||
|
||||
if (maybeQuestion is not { } question)
|
||||
if (!(maybeQuestion is TriviaQuestion question))
|
||||
{
|
||||
// if question is null (ran out of question, or other bugg ) - stop
|
||||
break;
|
||||
@@ -110,8 +110,7 @@ public sealed class TriviaGame
|
||||
var guessed = false;
|
||||
while (true)
|
||||
{
|
||||
using var readCancel = new CancellationTokenSource();
|
||||
var readTask = _inputs.Reader.ReadAsync(readCancel.Token).AsTask();
|
||||
var readTask = _inputs.Reader.ReadAsync().AsTask();
|
||||
|
||||
// wait for either someone to attempt to guess
|
||||
// or for timeout
|
||||
@@ -120,8 +119,6 @@ public sealed class TriviaGame
|
||||
// if the task which completed is the timeout task
|
||||
if (task == halfGuessTimerTask)
|
||||
{
|
||||
readCancel.Cancel();
|
||||
|
||||
// if hint is already sent, means time expired
|
||||
// break (end the round)
|
||||
if (hintSent)
|
||||
@@ -150,7 +147,6 @@ public sealed class TriviaGame
|
||||
|
||||
// reset inactivity counter
|
||||
inactivity = 0;
|
||||
errorCount = 0;
|
||||
|
||||
var isWin = false;
|
||||
// if user won the game, tell the game to stop
|
||||
@@ -178,9 +174,9 @@ public sealed class TriviaGame
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch
|
||||
{
|
||||
Log.Error(ex, "Fatal error in trivia game: {ErrorMessage}", ex.Message);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -424,7 +424,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Log.Information("No old version list found. Creating a new one");
|
||||
Log.Information("No old version list found. Creating a new one.");
|
||||
}
|
||||
|
||||
var versionList = JsonSerializer.Deserialize<List<string>>(versionListString);
|
||||
@@ -469,7 +469,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
"https://nadekobot.readthedocs.io/en/latest/"));
|
||||
|
||||
|
||||
private Task SelfhostAction(SocketMessageComponent smc, object _)
|
||||
private Task SelfhostAction(SocketMessageComponent smc)
|
||||
=> smc.RespondConfirmAsync(_eb,
|
||||
@"- In case you don't want or cannot Donate to NadekoBot project, but you
|
||||
- NadekoBot is a completely free and fully [open source](https://gitlab.com/kwoth/nadekobot) project which means you can run your own ""selfhosted"" instance on your computer or server for free.
|
||||
@@ -484,13 +484,7 @@ public partial class Help : NadekoModule<HelpService>
|
||||
[OnlyPublicBot]
|
||||
public async Task Donate()
|
||||
{
|
||||
// => new NadekoInteractionData(new Emoji("🖥️"), "donate:selfhosting", "Selfhosting");
|
||||
var selfhostInter = _inter.Create(ctx.User.Id,
|
||||
new SimpleInteraction<object>(new ButtonBuilder(
|
||||
emote: new Emoji("🖥️"),
|
||||
customId: "donate:selfhosting",
|
||||
label: "Selfhosting"),
|
||||
SelfhostAction));
|
||||
var selfhostInter = new DonateSelfhostingInteraction(_client, ctx.User.Id, SelfhostAction);
|
||||
|
||||
var eb = _eb.Create(ctx)
|
||||
.WithOkColor()
|
||||
@@ -531,7 +525,7 @@ Nadeko will DM you the welcome instructions, and you may start using the patron-
|
||||
|
||||
try
|
||||
{
|
||||
await (await ctx.User.CreateDMChannelAsync()).EmbedAsync(eb, inter: selfhostInter);
|
||||
await (await ctx.User.CreateDMChannelAsync()).EmbedAsync(eb, inter: selfhostInter.GetInteraction());
|
||||
_ = ctx.OkAsync();
|
||||
}
|
||||
catch
|
||||
|
@@ -0,0 +1,12 @@
|
||||
namespace NadekoBot.Modules.Help;
|
||||
|
||||
public class DonateSelfhostingInteraction : NInteraction
|
||||
{
|
||||
protected override NadekoInteractionData Data
|
||||
=> new NadekoInteractionData(new Emoji("🖥️"), "donate:selfhosting", "Selfhosting");
|
||||
|
||||
public DonateSelfhostingInteraction(DiscordSocketClient client, ulong userId, Func<SocketMessageComponent, Task> action)
|
||||
: base(client, userId, action)
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
namespace NadekoBot.Modules.Help;
|
||||
|
||||
public class DonateTroubleshootInteraction : NInteraction
|
||||
{
|
||||
protected override NadekoInteractionData Data
|
||||
=> new NadekoInteractionData(new Emoji("❓"), "donate:troubleshoot", "Troubleshoot");
|
||||
|
||||
public DonateTroubleshootInteraction(DiscordSocketClient client, ulong userId, Func<SocketMessageComponent, Task> action)
|
||||
: base(client, userId, action)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
#nullable disable
|
||||
using Nadeko.Common;
|
||||
using NadekoBot.Modules.Music.Services;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
|
@@ -1,119 +1,68 @@
|
||||
#nullable disable
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Services;
|
||||
|
||||
public sealed class CmdCdService : IExecPreCommand, IReadyExecutor, INService
|
||||
public class CmdCdService : IExecPreCommand, INService
|
||||
{
|
||||
private readonly ConcurrentDictionary<ulong, ConcurrentDictionary<string, int>> _settings = new();
|
||||
public ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>> CommandCooldowns { get; }
|
||||
public ConcurrentDictionary<ulong, ConcurrentHashSet<ActiveCooldown>> ActiveCooldowns { get; } = new();
|
||||
|
||||
private readonly ConcurrentDictionary<(ulong, string), ConcurrentDictionary<ulong, DateTime>> _activeCooldowns =
|
||||
new();
|
||||
|
||||
public int Priority => 0;
|
||||
public int Priority { get; } = 0;
|
||||
|
||||
public CmdCdService(Bot bot)
|
||||
=> CommandCooldowns = new(bot.AllGuildConfigs.ToDictionary(k => k.GuildId,
|
||||
v => new ConcurrentHashSet<CommandCooldown>(v.CommandCooldowns)));
|
||||
|
||||
public Task<bool> TryBlock(IGuild guild, IUser user, string commandName)
|
||||
{
|
||||
_settings = bot
|
||||
.AllGuildConfigs
|
||||
.ToDictionary(x => x.GuildId, x => x.CommandCooldowns
|
||||
.ToDictionary(c => c.CommandName, c => c.Seconds)
|
||||
.ToConcurrent())
|
||||
.ToConcurrent();
|
||||
if (guild is null)
|
||||
return Task.FromResult(false);
|
||||
|
||||
var cmdcds = CommandCooldowns.GetOrAdd(guild.Id, new ConcurrentHashSet<CommandCooldown>());
|
||||
CommandCooldown cdRule;
|
||||
if ((cdRule = cmdcds.FirstOrDefault(cc => cc.CommandName == commandName)) is not null)
|
||||
{
|
||||
var activeCdsForGuild = ActiveCooldowns.GetOrAdd(guild.Id, new ConcurrentHashSet<ActiveCooldown>());
|
||||
if (activeCdsForGuild.FirstOrDefault(ac => ac.UserId == user.Id && ac.Command == commandName) is not null)
|
||||
return Task.FromResult(true);
|
||||
|
||||
activeCdsForGuild.Add(new()
|
||||
{
|
||||
UserId = user.Id,
|
||||
Command = commandName
|
||||
});
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(cdRule.Seconds * 1000);
|
||||
activeCdsForGuild.RemoveWhere(ac => ac.Command == commandName && ac.UserId == user.Id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Task<bool> ExecPreCommandAsync(ICommandContext context, string moduleName, CommandInfo command)
|
||||
=> TryBlock(context.Guild, context.User, command.Name.ToLowerInvariant());
|
||||
|
||||
public async Task<bool> TryBlock(IGuild guild, IUser user, string commandName)
|
||||
{
|
||||
if (!_settings.TryGetValue(guild.Id, out var cooldownSettings))
|
||||
return false;
|
||||
|
||||
if (!cooldownSettings.TryGetValue(commandName, out var cdSeconds))
|
||||
return false;
|
||||
|
||||
var cooldowns = _activeCooldowns.GetOrAdd(
|
||||
(guild.Id, commandName),
|
||||
static _ => new());
|
||||
|
||||
// if user is not already on cooldown, add
|
||||
if (cooldowns.TryAdd(user.Id, DateTime.UtcNow))
|
||||
{
|
||||
return false;
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
// if there is an entry, maybe it expired. Try to check if it expired and don't fail if it did
|
||||
// - just update
|
||||
if (cooldowns.TryGetValue(user.Id, out var oldValue))
|
||||
public Task<bool> ExecPreCommandAsync(ICommandContext ctx, string moduleName, CommandInfo command)
|
||||
{
|
||||
var diff = DateTime.UtcNow - oldValue;
|
||||
if (diff.Seconds > cdSeconds)
|
||||
{
|
||||
if (cooldowns.TryUpdate(user.Id, DateTime.UtcNow, oldValue))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var guild = ctx.Guild;
|
||||
var user = ctx.User;
|
||||
var commandName = command.Name.ToLowerInvariant();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
using var timer = new PeriodicTimer(TimeSpan.FromHours(1));
|
||||
|
||||
while (await timer.WaitForNextTickAsync())
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
// once per hour delete expired entries
|
||||
foreach (var ((guildId, commandName), dict) in _activeCooldowns)
|
||||
{
|
||||
// if this pair no longer has associated config, that means it has been removed.
|
||||
// remove all cooldowns
|
||||
if (!_settings.TryGetValue(guildId, out var inner)
|
||||
|| !inner.TryGetValue(commandName, out var cdSeconds))
|
||||
{
|
||||
_activeCooldowns.Remove((guildId, commandName), out _);
|
||||
continue;
|
||||
}
|
||||
|
||||
Cleanup(dict, cdSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Cleanup(ConcurrentDictionary<ulong, DateTime> dict, int cdSeconds)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
foreach (var (key, _) in dict.Where(x => (now - x.Value).Seconds > cdSeconds).ToArray())
|
||||
{
|
||||
dict.TryRemove(key, out _);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearCooldowns(ulong guildId, string cmdName)
|
||||
{
|
||||
if (_settings.TryGetValue(guildId, out var dict))
|
||||
dict.TryRemove(cmdName, out _);
|
||||
|
||||
_activeCooldowns.TryRemove((guildId, cmdName), out _);
|
||||
}
|
||||
|
||||
public void AddCooldown(ulong guildId, string name, int secs)
|
||||
{
|
||||
var sett = _settings.GetOrAdd(guildId, static _ => new());
|
||||
sett[name] = secs;
|
||||
|
||||
// force cleanup
|
||||
if (_activeCooldowns.TryGetValue((guildId, name), out var dict))
|
||||
Cleanup(dict, secs);
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<(string CommandName, int Seconds)> GetCommandCooldowns(ulong guildId)
|
||||
{
|
||||
if (!_settings.TryGetValue(guildId, out var dict))
|
||||
return Array.Empty<(string, int)>();
|
||||
|
||||
return dict.Select(x => (x.Key, x.Value)).ToArray();
|
||||
return TryBlock(guild, user, commandName);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveCooldown
|
||||
{
|
||||
public string Command { get; set; }
|
||||
public ulong UserId { get; set; }
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
#nullable disable
|
||||
using Humanizer.Localisation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Common.TypeReaders;
|
||||
using NadekoBot.Db;
|
||||
@@ -13,6 +12,12 @@ public partial class Permissions
|
||||
[Group]
|
||||
public partial class CmdCdsCommands : NadekoModule
|
||||
{
|
||||
private ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>> CommandCooldowns
|
||||
=> _service.CommandCooldowns;
|
||||
|
||||
private ConcurrentDictionary<ulong, ConcurrentHashSet<ActiveCooldown>> ActiveCooldowns
|
||||
=> _service.ActiveCooldowns;
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly CmdCdService _service;
|
||||
|
||||
@@ -35,10 +40,12 @@ public partial class Permissions
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
var config = uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.CommandCooldowns));
|
||||
var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>());
|
||||
|
||||
var toDelete = config.CommandCooldowns.FirstOrDefault(cc => cc.CommandName == name);
|
||||
if (toDelete is not null)
|
||||
uow.Set<CommandCooldown>().Remove(toDelete);
|
||||
localSet.RemoveWhere(cc => cc.CommandName == name);
|
||||
if (secs != 0)
|
||||
{
|
||||
var cc = new CommandCooldown
|
||||
@@ -47,7 +54,7 @@ public partial class Permissions
|
||||
Seconds = secs
|
||||
};
|
||||
config.CommandCooldowns.Add(cc);
|
||||
_service.AddCooldown(channel.Guild.Id, name, secs);
|
||||
localSet.Add(cc);
|
||||
}
|
||||
|
||||
await uow.SaveChangesAsync();
|
||||
@@ -55,7 +62,8 @@ public partial class Permissions
|
||||
|
||||
if (secs == 0)
|
||||
{
|
||||
_service.ClearCooldowns(ctx.Guild.Id, cmdName);
|
||||
var activeCds = ActiveCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<ActiveCooldown>());
|
||||
activeCds.RemoveWhere(ac => ac.Command == name);
|
||||
await ReplyConfirmLocalizedAsync(strs.cmdcd_cleared(Format.Bold(name)));
|
||||
}
|
||||
else
|
||||
@@ -76,29 +84,19 @@ public partial class Permissions
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task AllCmdCooldowns(int page = 1)
|
||||
public async Task AllCmdCooldowns()
|
||||
{
|
||||
if (--page < 0)
|
||||
return;
|
||||
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
var localSet = _service.GetCommandCooldowns(ctx.Guild.Id);
|
||||
var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>());
|
||||
|
||||
if (!localSet.Any())
|
||||
await ReplyConfirmLocalizedAsync(strs.cmdcd_none);
|
||||
else
|
||||
{
|
||||
await ctx.SendPaginatedConfirmAsync(page, curPage =>
|
||||
{
|
||||
var items = localSet.Skip(curPage * 15)
|
||||
.Take(15)
|
||||
.Select(x => $"{Format.Code(x.CommandName)}: {x.Seconds.Seconds().Humanize(maxUnit: TimeUnit.Second, culture: Culture)}");
|
||||
|
||||
return _eb.Create(ctx)
|
||||
.WithOkColor()
|
||||
.WithDescription(items.Join("\n"));
|
||||
|
||||
}, localSet.Count, 15);
|
||||
await channel.SendTableAsync("",
|
||||
localSet.Select(c => c.CommandName + ": " + c.Seconds + GetText(strs.sec)),
|
||||
s => $"{s,-30}",
|
||||
2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ public partial class Searches
|
||||
public partial class FeedCommands : NadekoModule<FeedsService>
|
||||
{
|
||||
private static readonly Regex _ytChannelRegex =
|
||||
new(@"youtube\.com\/(?:c\/|channel\/|user\/)?(?<channelid>[a-zA-Z0-9\-_]{1,})");
|
||||
new(@"youtube\.com\/(?:c\/|channel\/|user\/)?(?<channelid>[a-zA-Z0-9\-]{1,})");
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
|
@@ -1,4 +1,6 @@
|
||||
#nullable disable
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Nadeko.Common;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
@@ -10,6 +12,95 @@ using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Services;
|
||||
|
||||
public sealed class StreamOnlineMessageDeleterService : INService, IReadyExecutor
|
||||
{
|
||||
private readonly StreamNotificationService _notifService;
|
||||
private readonly DbService _db;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IPubSub _pubSub;
|
||||
|
||||
public StreamOnlineMessageDeleterService(
|
||||
StreamNotificationService notifService,
|
||||
DbService db,
|
||||
IPubSub pubSub,
|
||||
DiscordSocketClient client)
|
||||
{
|
||||
_notifService = notifService;
|
||||
_db = db;
|
||||
_client = client;
|
||||
_pubSub = pubSub;
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
_notifService.OnlineMessagesSent += OnOnlineMessagesSent;
|
||||
|
||||
if(_client.ShardId == 0)
|
||||
await _pubSub.Sub(_notifService.StreamsOfflineKey, OnStreamsOffline);
|
||||
}
|
||||
|
||||
private async Task OnOnlineMessagesSent(FollowedStream.FType type, string name, IReadOnlyCollection<(ulong, ulong)> pairs)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
foreach (var (channelId, messageId) in pairs)
|
||||
{
|
||||
await ctx.GetTable<StreamOnlineMessage>()
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
Name = name,
|
||||
Type = type,
|
||||
MessageId = messageId,
|
||||
ChannelId = channelId,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async ValueTask OnStreamsOffline(List<StreamData> streamDatas)
|
||||
{
|
||||
if (_client.ShardId != 0)
|
||||
return;
|
||||
|
||||
var pairs = await GetMessagesToDelete(streamDatas);
|
||||
|
||||
foreach (var (channelId, messageId) in pairs)
|
||||
{
|
||||
try
|
||||
{
|
||||
var textChannel = await _client.GetChannelAsync(channelId) as ITextChannel;
|
||||
if (textChannel is null)
|
||||
continue;
|
||||
|
||||
await textChannel.DeleteMessageAsync(messageId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<(ulong, ulong)>> GetMessagesToDelete(List<StreamData> streamDatas)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
|
||||
var toReturn = new List<(ulong, ulong)>();
|
||||
foreach (var sd in streamDatas)
|
||||
{
|
||||
var key = sd.CreateKey();
|
||||
var toDelete = await ctx.GetTable<StreamOnlineMessage>()
|
||||
.Where(x => (x.Type == key.Type && x.Name == key.Name)
|
||||
|| Sql.DateDiff(Sql.DateParts.Day, x.DateAdded, DateTime.UtcNow) > 1)
|
||||
.DeleteWithOutputAsync();
|
||||
|
||||
toReturn.AddRange(toDelete.Select(x => (x.ChannelId, x.MessageId)));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
{
|
||||
private readonly DbService _db;
|
||||
@@ -279,7 +370,7 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
|
||||
var message = string.IsNullOrWhiteSpace(fs.Message) ? "" : rep.Replace(fs.Message);
|
||||
|
||||
var msg = await textChannel.EmbedAsync(GetEmbed(fs.GuildId, stream, false), message);
|
||||
var msg = await textChannel.EmbedAsync(GetEmbed(fs.GuildId, stream), message);
|
||||
|
||||
// only cache the ids of channel/message pairs
|
||||
if(_deleteOnOfflineServers.Contains(fs.GuildId))
|
||||
@@ -472,22 +563,18 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
return data;
|
||||
}
|
||||
|
||||
public IEmbedBuilder GetEmbed(ulong guildId, StreamData status, bool showViewers = true)
|
||||
public IEmbedBuilder GetEmbed(ulong guildId, StreamData status)
|
||||
{
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(status.Name)
|
||||
.WithUrl(status.StreamUrl)
|
||||
.WithDescription(status.StreamUrl)
|
||||
.AddField(GetText(guildId, strs.status), status.IsLive ? "🟢 Online" : "🔴 Offline", true);
|
||||
|
||||
if (showViewers)
|
||||
{
|
||||
embed.AddField(GetText(guildId, strs.viewers),
|
||||
.AddField(GetText(guildId, strs.status), status.IsLive ? "🟢 Online" : "🔴 Offline", true)
|
||||
.AddField(GetText(guildId, strs.viewers),
|
||||
status.Viewers == 0 && !status.IsLive
|
||||
? "-"
|
||||
: status.Viewers,
|
||||
true);
|
||||
}
|
||||
|
||||
if (status.IsLive)
|
||||
embed = embed.WithOkColor();
|
||||
|
@@ -1,99 +0,0 @@
|
||||
#nullable disable
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Db.Models;
|
||||
using NadekoBot.Modules.Searches.Common;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Services;
|
||||
|
||||
public sealed class StreamOnlineMessageDeleterService : INService, IReadyExecutor
|
||||
{
|
||||
private readonly StreamNotificationService _notifService;
|
||||
private readonly DbService _db;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IPubSub _pubSub;
|
||||
|
||||
public StreamOnlineMessageDeleterService(
|
||||
StreamNotificationService notifService,
|
||||
DbService db,
|
||||
IPubSub pubSub,
|
||||
DiscordSocketClient client)
|
||||
{
|
||||
_notifService = notifService;
|
||||
_db = db;
|
||||
_client = client;
|
||||
_pubSub = pubSub;
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
_notifService.OnlineMessagesSent += OnOnlineMessagesSent;
|
||||
|
||||
if (_client.ShardId == 0)
|
||||
await _pubSub.Sub(_notifService.StreamsOfflineKey, OnStreamsOffline);
|
||||
}
|
||||
|
||||
private async Task OnOnlineMessagesSent(
|
||||
FollowedStream.FType type,
|
||||
string name,
|
||||
IReadOnlyCollection<(ulong, ulong)> pairs)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
foreach (var (channelId, messageId) in pairs)
|
||||
{
|
||||
await ctx.GetTable<StreamOnlineMessage>()
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
Name = name,
|
||||
Type = type,
|
||||
MessageId = messageId,
|
||||
ChannelId = channelId,
|
||||
DateAdded = DateTime.UtcNow,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async ValueTask OnStreamsOffline(List<StreamData> streamDatas)
|
||||
{
|
||||
if (_client.ShardId != 0)
|
||||
return;
|
||||
|
||||
var pairs = await GetMessagesToDelete(streamDatas);
|
||||
|
||||
foreach (var (channelId, messageId) in pairs)
|
||||
{
|
||||
try
|
||||
{
|
||||
var textChannel = await _client.GetChannelAsync(channelId) as ITextChannel;
|
||||
if (textChannel is null)
|
||||
continue;
|
||||
|
||||
await textChannel.DeleteMessageAsync(messageId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<(ulong, ulong)>> GetMessagesToDelete(List<StreamData> streamDatas)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
|
||||
var toReturn = new List<(ulong, ulong)>();
|
||||
foreach (var sd in streamDatas)
|
||||
{
|
||||
var key = sd.CreateKey();
|
||||
var toDelete = await ctx.GetTable<StreamOnlineMessage>()
|
||||
.Where(x => (x.Type == key.Type && x.Name == key.Name)
|
||||
|| Sql.DateDiff(Sql.DateParts.Day, x.DateAdded, DateTime.UtcNow) > 1)
|
||||
.DeleteWithOutputAsync();
|
||||
|
||||
toReturn.AddRange(toDelete.Select(x => (x.ChannelId, x.MessageId)));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
@@ -98,33 +98,6 @@ public partial class Utility
|
||||
await ctx.Channel.EmbedAsync(embed);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireUserPermission(GuildPermission.ManageRoles)]
|
||||
public async Task RoleInfo([Leftover] SocketRole role)
|
||||
{
|
||||
if (role.IsEveryone)
|
||||
return;
|
||||
|
||||
var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)
|
||||
.AddMilliseconds(role.Id >> 22);
|
||||
var usercount = role.Members.LongCount();
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(role.Name.TrimTo(128))
|
||||
.WithDescription(role.Permissions.ToList().Join(" | "))
|
||||
.AddField(GetText(strs.id), role.Id.ToString(), true)
|
||||
.AddField(GetText(strs.created_at), $"{createdAt:dd.MM.yyyy HH:mm}", true)
|
||||
.AddField(GetText(strs.users), usercount.ToString(), true)
|
||||
.AddField(GetText(strs.color), $"#{role.Color.R:X2}{role.Color.G:X2}{role.Color.B:X2}", true)
|
||||
.AddField(GetText(strs.mentionable), role.IsMentionable.ToString(), true)
|
||||
.AddField(GetText(strs.hoisted), role.IsHoisted.ToString(), true)
|
||||
.WithOkColor();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(role.GetIconUrl()))
|
||||
embed = embed.WithThumbnailUrl(role.GetIconUrl());
|
||||
|
||||
await ctx.Channel.EmbedAsync(embed);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task UserInfo(IGuildUser usr = null)
|
||||
@@ -138,10 +111,8 @@ public partial class Utility
|
||||
if (!string.IsNullOrWhiteSpace(user.Nickname))
|
||||
embed.AddField(GetText(strs.nickname), user.Nickname, true);
|
||||
|
||||
var joinedAt = GetJoinedAt(user);
|
||||
|
||||
embed.AddField(GetText(strs.id), user.Id.ToString(), true)
|
||||
.AddField(GetText(strs.joined_server), $"{joinedAt?.ToString("dd.MM.yyyy HH:mm") ?? "?"}", true)
|
||||
.AddField(GetText(strs.joined_server), $"{user.JoinedAt?.ToString("dd.MM.yyyy HH:mm") ?? "?"}", true)
|
||||
.AddField(GetText(strs.joined_discord), $"{user.CreatedAt:dd.MM.yyyy HH:mm}", true)
|
||||
.AddField(GetText(strs.roles),
|
||||
$"**({user.RoleIds.Count - 1})** - {string.Join("\n", user.GetRoles().Take(10).Where(r => r.Id != r.Guild.EveryoneRole.Id).Select(r => r.Name)).SanitizeMentions(true)}",
|
||||
@@ -169,18 +140,6 @@ public partial class Utility
|
||||
await ctx.Channel.EmbedAsync(embed);
|
||||
}
|
||||
|
||||
private DateTimeOffset? GetJoinedAt(IGuildUser user)
|
||||
{
|
||||
var joinedAt = user.JoinedAt;
|
||||
if (user.GuildId != 117523346618318850)
|
||||
return joinedAt;
|
||||
|
||||
if (user.Id == 351244576092192778)
|
||||
return new DateTimeOffset(2019, 12, 25, 9, 33, 0, TimeSpan.Zero);
|
||||
|
||||
return joinedAt;
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
|
@@ -286,7 +286,8 @@ public sealed class PatronageService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> ExecPreCommandAsync(ICommandContext ctx,
|
||||
public async Task<bool> ExecPreCommandAsync(
|
||||
ICommandContext ctx,
|
||||
string moduleName,
|
||||
CommandInfo command)
|
||||
{
|
||||
|
@@ -1,6 +0,0 @@
|
||||
namespace NadekoBot.Modules.Utility;
|
||||
|
||||
public interface IQuoteService
|
||||
{
|
||||
Task<int> DeleteAllAuthorQuotesAsync(ulong guildId, ulong userId);
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
#nullable disable warnings
|
||||
#nullable disable warnings
|
||||
using Nadeko.Common;
|
||||
using NadekoBot.Common.Yml;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
@@ -33,13 +34,11 @@ public partial class Utility
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly IHttpClientFactory _http;
|
||||
private readonly IQuoteService _qs;
|
||||
|
||||
public QuoteCommands(DbService db, IQuoteService qs, IHttpClientFactory http)
|
||||
public QuoteCommands(DbService db, IHttpClientFactory http)
|
||||
{
|
||||
_db = db;
|
||||
_http = http;
|
||||
_qs = qs;
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -109,7 +108,7 @@ public partial class Utility
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task QuoteShow(int id)
|
||||
{
|
||||
Quote? quote;
|
||||
Quote quote;
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
quote = uow.Quotes.GetById(id);
|
||||
@@ -257,28 +256,6 @@ public partial class Utility
|
||||
await SendErrorAsync(response);
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public Task QuoteDeleteAuthor(IUser user)
|
||||
=> QuoteDeleteAuthor(user.Id);
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task QuoteDeleteAuthor(ulong userId)
|
||||
{
|
||||
var hasManageMessages = ((IGuildUser)ctx.Message.Author).GuildPermissions.ManageMessages;
|
||||
|
||||
if (userId == ctx.User.Id || hasManageMessages)
|
||||
{
|
||||
var deleted = await _qs.DeleteAllAuthorQuotesAsync(ctx.Guild.Id, ctx.User.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.quotes_deleted_count(deleted));
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.insuf_perms_u);
|
||||
}
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.ManageMessages)]
|
||||
@@ -326,7 +303,7 @@ public partial class Utility
|
||||
#if GLOBAL_NADEKO
|
||||
[OwnerOnly]
|
||||
#endif
|
||||
public async Task QuotesImport([Leftover] string? input = null)
|
||||
public async Task QuotesImport([Leftover] string input = null)
|
||||
{
|
||||
input = input?.Trim();
|
||||
|
||||
|
@@ -1,32 +0,0 @@
|
||||
#nullable disable warnings
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Utility;
|
||||
|
||||
public sealed class QuoteService : IQuoteService, INService
|
||||
{
|
||||
private readonly DbService _db;
|
||||
|
||||
public QuoteService(DbService db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete all quotes created by the author in a guild
|
||||
/// </summary>
|
||||
/// <param name="guildId">ID of the guild</param>
|
||||
/// <param name="userId">ID of the user</param>
|
||||
/// <returns>Number of deleted qutoes</returns>
|
||||
public async Task<int> DeleteAllAuthorQuotesAsync(ulong guildId, ulong userId)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
var deleted = await ctx.GetTable<Quote>()
|
||||
.Where(x => x.GuildId == guildId && x.AuthorId == userId)
|
||||
.DeleteAsync();
|
||||
|
||||
return deleted;
|
||||
}
|
||||
}
|
@@ -159,18 +159,6 @@ public class RemindService : INService, IReadyExecutor
|
||||
if (ch is null)
|
||||
return;
|
||||
|
||||
var st = SmartText.CreateFrom(r.Message);
|
||||
|
||||
if (st is SmartEmbedText set)
|
||||
{
|
||||
await ch.SendMessageAsync(null, embed: set.GetEmbed().Build());
|
||||
}
|
||||
else if (st is SmartEmbedTextArray seta)
|
||||
{
|
||||
await ch.SendMessageAsync(null, embeds: seta.GetEmbedBuilders().Map(x => x.Build()));
|
||||
}
|
||||
else
|
||||
{
|
||||
await ch.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("Reminder")
|
||||
@@ -180,7 +168,6 @@ public class RemindService : INService, IReadyExecutor
|
||||
(await ch.GetUserAsync(r.UserId))?.ToString() ?? r.UserId.ToString()),
|
||||
r.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "Error executing reminder {ReminderId}: {ErrorMessage}", r.Id, ex.Message);
|
||||
|
@@ -367,41 +367,6 @@ public partial class Utility : NadekoModule
|
||||
await ConfirmLocalizedAsync(strs.emoji_added(em.ToString()));
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[BotPerm(GuildPerm.ManageEmojisAndStickers)]
|
||||
[UserPerm(GuildPerm.ManageEmojisAndStickers)]
|
||||
[Priority(0)]
|
||||
public async Task EmojiRemove(params Emote[] emotes)
|
||||
{
|
||||
if (emotes.Length == 0)
|
||||
return;
|
||||
|
||||
var g = (SocketGuild)ctx.Guild;
|
||||
|
||||
var fails = new List<Emote>();
|
||||
foreach (var emote in emotes)
|
||||
{
|
||||
var guildEmote = g.Emotes.FirstOrDefault(x => x.Id == emote.Id);
|
||||
if (guildEmote is null)
|
||||
{
|
||||
fails.Add(emote);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ctx.Guild.DeleteEmoteAsync(guildEmote);
|
||||
}
|
||||
}
|
||||
|
||||
if (fails.Count > 0)
|
||||
{
|
||||
await ReplyPendingLocalizedAsync(strs.emoji_not_removed(fails.Select(x => x.ToString()).Join(" ")));
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
public async Task ListServers(int page = 1)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user