我想用嵌入的消息进行表决。
当有人添加反应时,我想添加一个喜欢并显示嵌入中的喜欢数量。这里是一个例子:

每当有人点击like时,我所有的代码行都会工作,而我最终将所链接的Field值更改为:
messageReaction.message.embeds[0].fields[0] = "Some much like";
Run Code Online (Sandbox Code Playgroud)
但是嵌入消息不会更新。
我尝试使用以下方法更新消息:
function doAfakeEdit(message){
message.edit(message.content);
}
Run Code Online (Sandbox Code Playgroud)
它仍然保留该字段的旧值。
我该怎么办?
我有一个不和谐的机器人,我只是想知道:我如何找出机器人所在的公会?所以如果我说它 -guilds会告诉我它在多少公会。
我尝试将使用Node.js制作的discord bot部署到Heroku,构建成功但应用程序崩溃并抛出错误:
Error R10 (Boot timeout)
Web process failed to bind to $PORT within 60 seconds of launch
Run Code Online (Sandbox Code Playgroud)
我的Procfile:
web: node app.js
Run Code Online (Sandbox Code Playgroud)
package.json:
{
"name": "bot",
"version": "5.0",
"description": "Discord Bot",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "me",
"license": "MIT",
"dependencies": {
"discord.js": "^11.3.2",
"ffmpeg-binaries": "^3.2.2-3",
}
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序需要几秒钟才能启动localy.
我怎样才能解决这个问题?
我需要有关 Laravel Socialite 的帮助。
我使用谷歌服务来预验证我的应用程序。
Socialite::driver('google')->user()->token
Run Code Online (Sandbox Code Playgroud)
上述令牌是否等于 Google 访问令牌?
我正在创建一个“用户信息”命令,该命令返回用户的 Discord 用户名、ID、服务器加入日期以及他们是否在线。我可以通过user.id、user.username、 和显示所有信息user.presence.status。但当我尝试使用时,user.joinedAt我进入undefined了显示屏。
我知道这是因为User类和GuildMember类不一样,并且类GuildMember包含一个User对象。但我的问题是:如何从用户提及中
获取数据?.joinedAt
这是我当前的代码:
let user = message.mentions.users.first();
let embed = new Discord.RichEmbed()
.setColor('#4286f4')
.addField("Full Username:", `${user.username}#${user.discriminator}`)
.addField("User ID:", `${user.id}`)
.addField("Server Join Date:", `${user.joinedAt}`)
.addField("Online Status:", `${user.presence.status}`)
.setThumbnail(user.avatarURL);
message.channel.send(embed);
Run Code Online (Sandbox Code Playgroud) 我将以下 json 插入到预先创建的 BigQuery 表中。
\n\n{\n "Member_ID": 881230,\n "First_Name": "Dave2",\n "Last_Name": "Manin2",\n "Gender": "M",\n "Age": 53,\n "Height": "5,2",\n "Weight": 145,\n "Hours_Sleep": 4,\n "Calories_Consumed": 2497,\n "Exercise_Calories_Burned": 876,\n "Date": "2018-10-17"\n}\nRun Code Online (Sandbox Code Playgroud)\n\n当我将上面的行直接插入表中时,它工作正常,但通过函数出错(请参阅下面的完整错误消息)。我缺少什么?任何帮助表示赞赏。
\n\n这是我的node.js(代码后的错误消息)
\n\nexports.subscribe = function (event, callback) {\n const BigQuery = require(\'@google-cloud/bigquery\');\n const projectId = "mydemo-221920"; //Enter your project ID here\n const datasetId = "mydemodata"; //Enter your BigQuery dataset name here\n const tableId = "memid"; //Enter your BigQuery table name here -- make sure it is setup correctly\n …Run Code Online (Sandbox Code Playgroud) google-bigquery google-cloud-platform google-cloud-functions google-publisher-tag
我正试图从我即将进行的项目中抛弃 jQuery。我找到了一种使用纯 Vanilla JS 在滚动上创建粘性导航的方法,并希望导航上的链接在到达相应部分时更改其活动状态。
下面是我提出的工作解决方案,但我确信可以改进代码以编程方式工作,而无需为每个元素选择和创建条件。
我也使用了很多不同的选择器,我很确定一定有办法改进它,也许在循环中使用querySelectorAll和添加一个,但我也不能让它工作。谢谢你的帮助!eventListenerforEach
// select links
const allLinks = document.querySelectorAll('header nav ul li');
const linkTop = document.querySelector('#linkTop');
const linkAbout = document.querySelector('#linkAbout');
const linkServices = document.querySelector('#linkServices');
const linkClients = document.querySelector('#linkClients');
const linkContact = document.querySelector('#linkContact');
// select sections
const sectionTop = document.querySelector('#top');
const sectionAbout = document.querySelector('#about');
const sectionServices = document.querySelector('#services');
const sectionClients = document.querySelector('#clients');
const sectionContact = document.querySelector('#contact');
function changeLinkState() {
// home
if (window.scrollY >= sectionTop.offsetTop) {
allLinks.forEach(link => {
link.classList.remove('active');
});
linkTop.classList.add('active'); …Run Code Online (Sandbox Code Playgroud)我在将图像集成到 text/html JTextPane 时遇到问题。JTextPane 使用以下文本初始化:
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我插入文本:
kit.insertHTML(doc, doc.getLength(), "<b>" + string + "</b><br>" , 0, 0, HTML.Tag.B);
Run Code Online (Sandbox Code Playgroud)
以这种方式插入的所有文本都会正确显示,但是当我尝试使用以下命令插入 base64 编码的图像时:
kit.insertHTML(doc,doc.getLength(), "<img src=\"data:image/jpeg;base64," + base64Code + "\"/>", 0, 0, HTML.Tag.IMG);
Run Code Online (Sandbox Code Playgroud)
我只得到了一个占位符图像。当尝试使用正常的源路径时,它起作用了。然而,在线获取 Base64 代码并使用它也为我提供了一个占位符图像,而完全相同的代码可以在 w3school.com 的 HTML tryit 编辑器上运行。
假设我创建了一个嵌入并将其发送到一个频道。这是嵌入的:
const embed = new Discord.RichEmbed()
.setColor(color)
.setTitle(`${message.author.tag} wants to play.`)
.setAuthor(message.author.tag, message.author.displayAvatarURL)
.setDescription(game)
.setThumbnail(icon)
.addField(`\u200b\n**React with ${emoji} to join.**`, "Remove your reaction to leave.");
Run Code Online (Sandbox Code Playgroud)
发送后,我想编辑该嵌入的标题和描述,然后删除我在末尾添加的字段。
这是我正在尝试创建的新嵌入:
const embed = new Discord.RichEmbed(reaction.message.embeds[0])
.setTitle("This game has ended.")
.setDescription("You can no longer join.");
Run Code Online (Sandbox Code Playgroud)
这会更改标题和描述,但我不确定如何删除我添加的字段。
我有一个RichEmbed,我想制作它以便我可以有一个字段标题,当我点击它时,它会引导我到一个链接。
discord.js ×6
javascript ×4
node.js ×4
discord ×2
api ×1
ecmascript-6 ×1
google-oauth ×1
heroku ×1
html ×1
java ×1
jtextpane ×1
laravel ×1
php ×1
url ×1