当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript js.RichEmbed.setAuthor方法代码示例

本文整理汇总了TypeScript中discord.js.RichEmbed.setAuthor方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.RichEmbed.setAuthor方法的具体用法?TypeScript js.RichEmbed.setAuthor怎么用?TypeScript js.RichEmbed.setAuthor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord.js.RichEmbed的用法示例。


在下文中一共展示了js.RichEmbed.setAuthor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: warn

  warn(info: string, callback?: () => void) {
    this.findInfo();
    if (this.client.readyAt == null) { return; }

    const embed = new RichEmbed();
    embed.setAuthor("Weeb Bot");
    embed.setColor("RED");
    embed.addField("WARNING", info);

    this.channel.send(embed);
  }
开发者ID:KazeSenoue,项目名称:WeebBot-v2,代码行数:11,代码来源:discordTransporter.ts

示例2: GetEmbedForReply

    public async GetEmbedForReply(
        event: IMatrixEvent,
        channel: Discord.TextChannel,
    ): Promise<Discord.RichEmbed|undefined> {
        if (!event.content) {
            event.content = {};
        }

        const relatesTo = event.content["m.relates_to"];
        let eventId = "";
        if (relatesTo && relatesTo["m.in_reply_to"]) {
            eventId = relatesTo["m.in_reply_to"].event_id;
        } else {
            return;
        }

        const intent = this.bridge.getIntent();
        // Try to get the event.
        try {
            const sourceEvent = await intent.getEvent(event.room_id, eventId);
            sourceEvent.content.body = sourceEvent.content.body  || "Reply with unknown content";
            const replyEmbed = (await this.EventToEmbed(sourceEvent, channel, false)).messageEmbed;

            // if we reply to a discord member, ping them!
            if (this.bridge.getBot().isRemoteUser(sourceEvent.sender)) {
                const uid = new MatrixUser(sourceEvent.sender.replace("@", "")).localpart.substring("_discord".length);
                replyEmbed.addField("ping", `<@${uid}>`);
            }

            replyEmbed.setTimestamp(new Date(sourceEvent.origin_server_ts));

            if (this.HasAttachment(sourceEvent)) {
                const mxClient = this.bridge.getClientFactory().getClientAs();
                const url = mxClient.mxcUrlToHttp(sourceEvent.content.url);
                if (["m.image", "m.sticker"].includes(sourceEvent.content.msgtype as string)
                    || sourceEvent.type === "m.sticker") {
                    // we have an image reply
                    replyEmbed.setImage(url);
                } else {
                    const name = this.GetFilenameForMediaEvent(sourceEvent.content);
                    replyEmbed.description = `[${name}](${url})`;
                }
            }
            return replyEmbed;
        } catch (ex) {
            log.warn("Failed to handle reply, showing a unknown embed:", ex);
        }
        // For some reason we failed to get the event, so using fallback.
        const embed = new Discord.RichEmbed();
        embed.setDescription("Reply with unknown content");
        embed.setAuthor("Unknown");
        return embed;
    }
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:53,代码来源:matrixeventprocessor.ts

示例3:

 const buildMessage = (eqs: IEQ[], ships: number[]) => {
   let shipnumbers = [":one:", ":two:", ":three:", ":four:", ":five:", ":six:", ":seven:", ":eight:", ":nine:", ":keycap_ten:"];
   const embed = new Discord.RichEmbed();
   embed.setAuthor("PSO2 Emergency Quest Alert", "https://images.emojiterra.com/mozilla/512px/231a.png");
   embed.setColor("GREEN");
   embed.setDescription('<:H_Line_Bold:386614101503246348>Ships<:H_Line_Bold:386614101503246348>');
   eqs
     .filter(eq => ships.includes(eq.ship))
     .forEach(eq => {
       embed.description += `\n •  ${shipnumbers[eq.ship - 1]}<:V_Line:386619978994024458>${eq.name}`;
     });
   if (eqs.length > 9) {
   embed.setDescription('<:H_Line_Bold:386614101503246348>All Ships<:H_Line_Bold:386614101503246348>');
   embed.description += `\n •  ${eqs[0].name}`;
   }
   embed.description += "\n\n[Help?](https://bit.ly/2KRb1De)";
   return embed;
 }
开发者ID:KazeSenoue,项目名称:WeebBot-v2,代码行数:18,代码来源:eqs.ts


注:本文中的discord.js.RichEmbed.setAuthor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。