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

Categories

0 votes
306 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...