run dotnet format
This commit is contained in:
@@ -21,7 +21,7 @@ namespace PluralKit.Bot.Interactive
|
||||
protected readonly TaskCompletionSource _tcs = new();
|
||||
protected Message _message { get; private set; }
|
||||
protected bool _running;
|
||||
|
||||
|
||||
protected BaseInteractive(Context ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
@@ -33,7 +33,7 @@ namespace PluralKit.Bot.Interactive
|
||||
{
|
||||
var dispatch = _ctx.Services.Resolve<InteractionDispatchService>();
|
||||
var customId = dispatch.Register(handler, Timeout);
|
||||
|
||||
|
||||
var button = new Button
|
||||
{
|
||||
Label = label,
|
||||
@@ -56,16 +56,17 @@ namespace PluralKit.Bot.Interactive
|
||||
|
||||
protected async Task Finish(InteractionContext? ctx = null)
|
||||
{
|
||||
foreach (var button in _buttons)
|
||||
foreach (var button in _buttons)
|
||||
button.Disabled = true;
|
||||
|
||||
if (ctx != null)
|
||||
await Update(ctx);
|
||||
else
|
||||
await _ctx.Rest.EditMessage(_message.ChannelId, _message.Id, new MessageEditRequest {
|
||||
else
|
||||
await _ctx.Rest.EditMessage(_message.ChannelId, _message.Id, new MessageEditRequest
|
||||
{
|
||||
Components = GetComponents()
|
||||
});
|
||||
|
||||
|
||||
_tcs.TrySetResult();
|
||||
}
|
||||
|
||||
@@ -95,12 +96,12 @@ namespace PluralKit.Bot.Interactive
|
||||
public void Setup(Context ctx)
|
||||
{
|
||||
var dispatch = ctx.Services.Resolve<InteractionDispatchService>();
|
||||
foreach (var button in _buttons)
|
||||
foreach (var button in _buttons)
|
||||
button.CustomId = dispatch.Register(button.Handler, Timeout);
|
||||
}
|
||||
|
||||
public abstract Task Start();
|
||||
|
||||
|
||||
public async Task Run()
|
||||
{
|
||||
if (_running)
|
||||
@@ -108,7 +109,7 @@ namespace PluralKit.Bot.Interactive
|
||||
_running = true;
|
||||
|
||||
await Start();
|
||||
|
||||
|
||||
var cts = new CancellationTokenSource(Timeout.ToTimeSpan());
|
||||
cts.Token.Register(() => _tcs.TrySetException(new TimeoutException("Action timed out")));
|
||||
|
||||
@@ -125,7 +126,7 @@ namespace PluralKit.Bot.Interactive
|
||||
protected void Cleanup()
|
||||
{
|
||||
var dispatch = _ctx.Services.Resolve<InteractionDispatchService>();
|
||||
foreach (var button in _buttons)
|
||||
foreach (var button in _buttons)
|
||||
dispatch.Unregister(button.CustomId!);
|
||||
}
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@ namespace PluralKit.Bot.Interactive
|
||||
|
||||
public MessageComponent ToMessageComponent() => new()
|
||||
{
|
||||
Type = ComponentType.Button,
|
||||
Label = Label,
|
||||
Style = Style,
|
||||
Type = ComponentType.Button,
|
||||
Label = Label,
|
||||
Style = Style,
|
||||
CustomId = CustomId,
|
||||
Disabled = Disabled
|
||||
};
|
||||
|
@@ -23,7 +23,7 @@ namespace PluralKit.Bot.Interactive
|
||||
|
||||
public string CancelLabel { get; set; } = "Cancel";
|
||||
public ButtonStyle CancelStyle { get; set; } = ButtonStyle.Secondary;
|
||||
|
||||
|
||||
public override async Task Start()
|
||||
{
|
||||
AddButton(ctx => OnButtonClick(ctx, true), AcceptLabel, AcceptStyle);
|
||||
@@ -32,7 +32,7 @@ namespace PluralKit.Bot.Interactive
|
||||
AllowedMentions mentions = null;
|
||||
|
||||
if (User != _ctx.Author.Id)
|
||||
mentions = new AllowedMentions {Users = new[] {User!.Value}};
|
||||
mentions = new AllowedMentions { Users = new[] { User!.Value } };
|
||||
|
||||
await Send(Message, mentions: mentions);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace PluralKit.Bot.Interactive
|
||||
await Update(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Result = result;
|
||||
await Finish(ctx);
|
||||
}
|
||||
@@ -82,11 +82,11 @@ namespace PluralKit.Bot.Interactive
|
||||
_running = true;
|
||||
|
||||
var queue = _ctx.Services.Resolve<HandlerQueue<MessageCreateEvent>>();
|
||||
|
||||
|
||||
var messageDispatch = queue.WaitFor(MessagePredicate, Timeout, cts.Token);
|
||||
|
||||
await Start();
|
||||
|
||||
|
||||
cts.Token.Register(() => _tcs.TrySetException(new TimeoutException("Action timed out")));
|
||||
|
||||
try
|
||||
@@ -101,7 +101,7 @@ namespace PluralKit.Bot.Interactive
|
||||
}
|
||||
}
|
||||
|
||||
public YesNoPrompt(Context ctx): base(ctx)
|
||||
public YesNoPrompt(Context ctx) : base(ctx)
|
||||
{
|
||||
User = ctx.Author.Id;
|
||||
}
|
||||
|
Reference in New Issue
Block a user