Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

c# - VS doesn't recognize ReplyAsync or NextMessageAsync

Using the Discord.Net (v2.0.0) and Discord.Addons.Interactive (v2.2.0) packages in Visual Studio 2019

I'm new to c# so I probably have some terminology wrong. I'm trying to access the ReplyAsync and NextMessageAsync functions but VS can't find them. I get an error: "The name 'ReplyAsync' does not exist in the current context." I've tried referencing Discord, Discord.Commands, and Discord.Addons.Interactive in the Using header section. The examples I've seen don't refer to others. My code is below:

using Discord;
using Discord.Addons.Interactive;
using Discord.Commands;
using Discord.WebSocket;
using System;
using System.IO;
using System.Threading.Tasks;

namespace SWNABot
{
    class Program
    {
        public static void Main(string[] args)...

        private DiscordSocketClient client;
        public async Task MainAsync()...

        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");
        }
    }
}

I took this function from the sample code at https://github.com/foxbot/Discord.Addons.Interactive/blob/master/SampleApp/Modules/SampleModule.cs


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...