我想在一个文本经常变化的机器人中写一些游戏。但是我不明白如果不使用声明的新变量该怎么做 请帮助形成一个永久按钮跳转,但没有硬代码
[Command("test_button")]
public async Task But(CommandContext ctx)
{
var button = await ctx.RespondAsync(m => m.WithContent("blya")
.AddComponents(new DiscordButtonComponent(ButtonStyle.Primary, "button-one", "button")));
var people = new string[] { "textAAA", "textBBB", "textCCC" };
var result = await button.WaitForButtonAsync();
await result.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate).ConfigureAwait(false);
await button.ModifyAsync(people[0]).ConfigureAwait(false);
// how to fix it?
var result2 = await button.WaitForButtonAsync();
await result2.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate).ConfigureAwait(false);
await button.ModifyAsync(people[1]).ConfigureAwait(false);
var result3 = await button.WaitForButtonAsync();
await result3.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate).ConfigureAwait(false);
await button.ModifyAsync(people[2]).ConfigureAwait(false);
我认为这可以通过委托或 => 来完成,但我还是编程新手,所以我不知道该怎么做 我将非常感谢您的建议或提示
我只需要一个循环“for”,我昏昏沉沉
for (int i = 0; i < 3; i++)
{
var result = await one.WaitForButtonAsync();
await result.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate).ConfigureAwait(false);
await one.ModifyAsync(text[i]).ConfigureAwait(false);
}