【问题标题】:Discord Bot [Help Needed] [closed]Discord Bot [需要帮助] [关闭]
【发布时间】:2018-02-15 12:33:55
【问题描述】:

我需要不和谐机器人和编码方面的帮助 我从未真正编写过不和谐机器人,所以这就是我需要帮助的地方。所以我需要帮助来制作一个不和谐的机器人聊天,就像我要制定规则一样,它可以让规则聊天像这样弹出

[用户名] ;规则 删除我说的信息 [机器人] 规则在这里

喜欢这张图片

【问题讨论】:

  • “我需要帮助”不是一个实际问题,而且范围太广,不适合 Stack Overflow 问题的范围。请查看How to Askhelp center,了解本网站的主题。
  • 欢迎来到 Stack Overflow。很明显你需要帮助,否则你不会在这里发帖,所以你不需要在你的标题或问题中这么说。相反,请使用该空间来实际解释您遇到的问题并提出具体问题。这不是代码编写服务或教程网站。请花一些时间阅读tour 并阅读help center,尤其是How to Ask,然后回来edit 你的问题。谢谢。

标签: discord


【解决方案1】:

该图像中的内容是嵌入。我认为,Discord.js 是一个非常用户友好的 Discord API。你可以找到文档here

丰富的嵌入随 Discord API 一起提供,而且它们非常易于使用。这是一个例子。

const embed = new Discord.RichEmbed()


  message.channel.send({embed});

要在嵌入的消息中实际添加一些内容,您需要向嵌入添加属性。它们如下:

属性:

.title("title name")
.setAuthor("Author Name", "URL to picture you want to the left of name, optional")
.setColor(hex color code)
.setDescription("text")
.setFooter("text", "URL to image")
.setImage("URL to image")
.setThumbnail("URL in top right of embed")
.setTimestamp()

时间戳在底部,函数中没有任何内容 属性,续:

.setURL("URL to make title clickable")
.addField("bold text",
"text")

这是您链接的图片中使用的内容,可以有多个字段。

还有一个属性:

.addBlankField(true)

要发送嵌入,在 discord.js 中,只需这样做

message.channel.send({embed}); 

你之前定义了嵌入

【讨论】:

  • 你能给我一个像图片一样的例子吗?
【解决方案2】:

这是相当长的回复,但我建议阅读整个内容。

StackExchange 是一个人们发布和讨论代码的社区。恕我直言,我可以向您保证,如果我们看不到您尝试过的内容或任何现有代码,包括我在内的任何人都不会为您编写代码。

如果您有相关产品可供人们查看并/或帮助您在此基础上进行开发,那么您在此网站上的运气肯定会更好。

同时,请在此处查看非官方用户 Discord API 服务器:https://discordapp.com/invite/discord-API

当我站在你的立场上时,这个 discord 服务器对于回答有关 Discord API 的任何问题都非常有帮助,因为那里 99.9% 的人都知道你的问题是什么以及如何解决它。在您构建代码时,人们总是在线回答您的问题。

如果您在启动代码方面需要帮助,基本步骤如下:

Pip 安装 discord API 在https://discordapp.com/developers/docs/intro 上创建机器人用户 使用机器人令牌编写代码 因为我不知道到目前为止你在你的机器人上取得了什么进展,所以我只是在 python 中串起了一些线框代码来开始。

import discord
import asyncio
from discord.ext import commands
description = "desc"
bot = commands.Bot(command_prefix='?', description=description)
#startup command
@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')
#category of main commands
class Main_Commands():
    def __init__(self, bot):
        self.bot = bot
#ping command test
@bot.command(pass_context=True)
async def ping(ctx):
    await bot.say("pong")
#when the user types in ?ping, the bot will return "pong"
#This is an example of a simple command in this language
#RunBot
bot.run("TOKEN GOES HERE")
# (C) 2017
# All rights reserved
# Any part of this program may be used and/or modified at the users discretion

无论如何,我希望这个回复对你有所帮助。

编码愉快!!

附:查看 API 参考 http://discordpy.readthedocs.io/en/latest/index.html

【讨论】:

    猜你喜欢
    • 2020-11-15
    • 1970-01-01
    • 2020-12-13
    • 2011-09-15
    • 2021-11-12
    • 2014-09-22
    • 2014-08-31
    • 2012-07-12
    • 1970-01-01
    相关资源
    最近更新 更多