小编and*_*son的帖子

如何在 discord.js 中等待回复?

所以我希望我的机器人做的是等待来自用户的消息,这样当用户发送“!spec”时,机器人会收到该消息并以“查看或更改?”作为响应。然后等你回输入“see”或“change”,但我不能让它工作。我不清楚这些文档,我不确定如何去做。

这必须能够在 PM 中工作,因为我不想用我计划做的事情向 Discord 发送垃圾邮件。

我已经试过了:

    if (command === 'spec'){
            message.author.send("See or Change?");
            const collector = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 10000 });
            console.log(collector)
            collector.on('collect', message => {
                if (message.content === "See") {
                    message.channel.send("You Want To See Someones Spec OK!");
                } else if (message.content === "Change") {
                    message.channel.send("You Want To Change Your Spec OK!");
                }
            })
Run Code Online (Sandbox Code Playgroud)

我可能写错了。我不习惯图书馆。

javascript discord

9
推荐指数
2
解决办法
4万
查看次数

道具未定义React js

我正在使用反应js,我不知道为什么我没有定义道具.

这是我的课.

import React, { Component } from 'react';

const InputHeight = {
    height: '50px',
}

function clearData() {
    this.refs.input.value = "";
}



export default class TextInput extends Component {
    render() {
        return (
            <input
                className="form-control"
                ref="input"
                name={props.name}
                type={props.inputType}
                value={props.content}
                pattern={props.pattern}
                onChange={props.controlFunc}
                placeholder={props.placeholder}
                style={InputHeight}
                required />
        );
    }
}


TextInput.propTypes = {
    inputType: React.PropTypes.oneOf(['text', 'number', 'email']).isRequired,
    name: React.PropTypes.string.isRequired,
    controlFunc: React.PropTypes.func.isRequired,
    content: React.PropTypes.oneOfType([
        React.PropTypes.string,
        React.PropTypes.number,
    ]).isRequired,
    placeholder: React.PropTypes.string,
};
Run Code Online (Sandbox Code Playgroud)

编译失败./src/components/Parts/SmallBits/FormItems/TextInput.js第19行:'道具'未定义no-undef第20行:'道具'未定义no-undef第21行:'道具'不是定义no-undef第22行:'props'未定义no-undef第23行:'props'未定义no-undef第24行:'props'未定义no-undef

搜索关键字以了解有关每个错误的更多信息.

this.refs.form.clearData();
Run Code Online (Sandbox Code Playgroud)

只是点击它,它给了我

未捕获的TypeError:无法读取null的属性'refs'

javascript jsx reactjs

8
推荐指数
1
解决办法
2万
查看次数

2
推荐指数
1
解决办法
1万
查看次数

C# Json 格式的响应

我知道我需要一个格式化的Newtonsoft Json回复,但我不知道该怎么做,而且我似乎找不到可以帮助我的教程或任何类型的文档。

这是我现在拥有的代码。dtb 是我需要以格式化Newtonsoft Json响应返回的数据库响应

da.Fill(dtb)
return Json(dtb);
Run Code Online (Sandbox Code Playgroud)

这不起作用,当我尝试运行下一批代码时出现错误

Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>((Newtonsoft.Json.Linq.JObject.Parse(response)["d"]).ToString());
UserModel m = (UserModel)JsonConvert.DeserializeObject<UserModel>(response);
if (m.Username == context.UserName && m.PasswordHash == myHash)
{
Run Code Online (Sandbox Code Playgroud)

我不知道为什么它在这个错误的第一行中断

+       $exception  {"Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1."}   Newtonsoft.Json.JsonReaderException
Run Code Online (Sandbox Code Playgroud)

错误编辑1:

Newtonsoft.Json.JsonSerializationException: 'Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'AuthorizationServer.api.Models.UserModel' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

To fix this error …
Run Code Online (Sandbox Code Playgroud)

c# json json.net

1
推荐指数
1
解决办法
1619
查看次数

标签 统计

javascript ×2

jsx ×2

reactjs ×2

c# ×1

discord ×1

eslint ×1

html ×1

json ×1

json.net ×1