如何使我的不和谐机器人以随机表情符号做出反应?

时间:2020-06-22 00:10:19

标签: bots discord discord.js

我正在使用discord.js和我的机器人,我试图使它在有人发送消息时以随机表情符号做出反应。到目前为止,这是我对某些行进行注释的内容,因为我不知道如何处理它们。 (我正在使用自定义表情符号)

顶部:

var emojisnop = [":vibing:698328721383227392",":snoopy5:724412122703855747",":snoopy4:724411949281968131",":snoopy3:724411826430804018",":snoopy2:724411667106103437"];

底部:

bot.on('message', message => {
    if (message) {
    return emojisnop = emojisnop[Math.floor(Math.random() * emojisnop.length)]
        message.react(':vibing:698328721383227392')
    }
});

任何帮助都会很棒

2 个答案:

答案 0 :(得分:1)

var emojisnop = ["698328721383227392","724412122703855747","724411949281968131","724411826430804018","724411667106103437"];

bot.on('message', message => {
    if (message) {
    return emojisnop = emojisnop[Math.floor(Math.random() * emojisnop.length)]
        message.react(emojisnop)
    }
});

对于custom emojis,请使用表情符号ID

答案 1 :(得分:0)

顶部:

DeleteCommand

底部:

public class GetNextPrevious {
    
    public static void main(String[] args) {
        
        getNextPrevious(11, "getNext", "getPrevious");
        
    }
    
    public static void getNextPrevious (Integer myInt, String getNext, String getPrevious) {
        
        List<Integer> intList = new ArrayList<Integer>();
        
        intList.add(1);intList.add(2);intList.add(3);intList.add(4);intList.add(5); 
        intList.add(6);intList.add(7);intList.add(8);intList.add(9);intList.add(10);
        
        for (int i=0; i<intList.size() ; i++) {
            
             Collections.sort(intList); 
             
             if (intList.contains(myInt)) {
                 
             if (myInt == intList.get(0)) {
                 System.out.println("Supplied " + myInt + " - is the MIN value in the list.");
                 break;
             }
             
             if (myInt == intList.get(intList.size()-1)) {
                 System.out.println("Supplied " + myInt + " - is the MAX value in the list.");
                 break;
             }
             
             if (getNext.length() != 0 && myInt == intList.get(i)) {
                 System.out.println("Next higher value is - " + intList.get(i+1));
             }
             
             if (getPrevious.length() != 0 && myInt == intList.get(i)) {
                 System.out.println("Next lower value is - " + intList.get(i-1));
             }
             
             } else {
                 System.out.println("....Invalid input....");
                 break;
             }
            
        }
        
    }
    
}