如何解决Discord.js嵌入未显示
我正在尝试使用discord.js制作嵌入消息,但是它不起作用。
这是我的代码:
library(heemod)
library(diagram)
library(shiny)
ui=shinyUI(fluidPage(
titlePanel("Markov Diagram Creator"),fluidRow(
sidebarPanel(
textAreaInput("statenames_1",label = "Enter state names here...",value = "H,S1,S2,D"),actionButton("go","Go")
),mainPanel(
hr(),plotOutput("plot")
)
)))
server=function(input,output){
state_names <- reactive( {
unlist(strsplit(x=input$statenames_1,split = "[[:punct:]]"))
})
len_states <- reactive({length(state_names())})
states <- reactive({state_names()})
statenames <- reactive({list(states(),states())})
markovTransitionMatrix <- reactive({matrix(0.25,nrow = len_states(),ncol = len_states(),dimnames = statenames())})
lis <- reactive({ as.list( markovTransitionMatrix() ) })
lis()$state_names <- reactive({ statenames() }) # Error in lis() <- reactive({ : invalid (NULL) left side of assignment
output$plot <- renderPlot({
plot(do.call( define_transition,lis() ),cex=0.75,ylim = c(0,.4))
})
}
shinyApp(ui,server)
解决方法
在此代码中,您必须定义MessageEmbed。如果您仅使用const Discord = require('discord.js');
,它将抛出ReferenceError,未定义MessageEmbed。请尝试new Discord.MessageEmbed()
或在代码顶部添加const { MessageEmbed } = require('discord.js');
。它将起作用。
PS:嗯,当我第一次启动discord.js机器人时,我也遇到了这个问题
,应该是这样
const Discord = require("discord.js")
client.on('message',message => {
if (message.content === 'how to embed') {
const embed = new Discord.MessageEmbed()
.setTitle('A slick little embed')
.setColor(0xff0000)
.setDescription('Hello,this is a slick embed!');
message.channel.send(embed);
}
});
您丢失了Discord.
MessageEmbed()
将 MessageEmbed() 更改为 Discord.MessageEmbed()
并确保你有 const Discord = require(‘discord.js’)
,首先你需要导入或要求 discord.js const discord = require('discord.js');
然后
let embed = new discord.MessageEmbed()
//your embed settings
然后你可以发送嵌入。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。