/
SampleModule.cs
44 lines (41 loc) 路 1.79 KB
/
SampleModule.cs
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
锘縰sing System;
using System.Threading.Tasks;
using Discord.Addons.Interactive;
using Discord.Commands;
namespace SampleApp.Modules
{
public class SampleModule : InteractiveBase
{
// DeleteAfterAsync will send a message and asynchronously delete it after the timeout has popped
// This method will not block.
[Command("delete")]
public async Task<RuntimeResult> Test_DeleteAfterAsync()
{
await ReplyAndDeleteAsync("this message will delete in 10 seconds", timeout: TimeSpan.FromSeconds(10));
return Ok();
}
// NextMessageAsync will wait for the next message to come in over the gateway, given certain criteria
// By default, this will be limited to messages from the source user in the source channel
// This method will block the gateway, so it should be ran in async mode.
[Command("next", RunMode = RunMode.Async)]
public async Task Test_NextMessageAsync()
{
await ReplyAsync("What is 2+2?");
var response = await NextMessageAsync();
if (response != null)
await ReplyAsync($"You replied: {response.Content}");
else
await ReplyAsync("You did not reply before the timeout");
}
// PagedReplyAsync will send a paginated message to the channel
// You can customize the paginator by creating a PaginatedMessage object
// You can customize the criteria for the paginator as well, which defaults to restricting to the source user
// This method will not block.
[Command("paginator")]
public async Task Test_Paginator()
{
var pages = new[] { "Page 1", "Page 2", "Page 3", "aaaaaa", "Page 5" };
await PagedReplyAsync(pages);
}
}
}