~ruther/NosSmooth.Local

ref: c4fcedefb7c78eaa71a09806509f9c3bca6f57d4 NosSmooth.Local/src/Samples/HighLevel/SimplePiiBot/Commands/ControlCommands.cs -rw-r--r-- 1.2 KiB
c4fcedef — Rutherther feat(samples): add simple pii bot sample 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
//  ControlCommands.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using OneOf.Types;
using Remora.Commands.Attributes;
using Remora.Commands.Groups;
using Remora.Results;

namespace SimplePiiBot.Commands;

/// <summary>
/// Commands for controlling the bot.
/// </summary>
public class ControlCommands : CommandGroup
{
    private readonly Bot _bot;

    /// <summary>
    /// Initializes a new instance of the <see cref="ControlCommands"/> class.
    /// </summary>
    /// <param name="bot">The bot.</param>
    public ControlCommands(Bot bot)
    {
        _bot = bot;
    }

    /// <summary>
    /// Handle the start command.
    /// </summary>
    /// <returns>A result that may or may not succeed.</returns>
    [Command("start")]
    public async Task<Result> HandleStartAsync()
        => await _bot.StartAsync(CancellationToken);

    /// <summary>
    /// Handle the stop command.
    /// </summary>
    /// <returns>A result that may or may not succeed.</returns>
    [Command("stop")]
    public async Task<Result> HandleStopAsync()
        => await _bot.StopAsync(CancellationToken);
}
Do not follow this link