How to use the eris.TextChannel function in eris

To help you get started, we’ve selected a few eris examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dragory / modmailbot / src / modules / close.js View on Github external
bot.on('channelDelete', async (channel) => {
    if (! (channel instanceof Eris.TextChannel)) return;
    if (channel.guild.id !== utils.getInboxGuild().id) return;

    const thread = await threads.findOpenThreadByChannelId(channel.id);
    if (! thread) return;

    console.log(`[INFO] Auto-closing thread with ${thread.user_name} because the channel was deleted`);
    if (config.closeMessage) await thread.postToUser(config.closeMessage).catch(() => {});
    await thread.close(true);

    const logUrl = await thread.getLogUrl();
    utils.postLog(utils.trimAll(`
      Modmail thread with ${thread.user_name} (${thread.user_id}) was closed automatically because the channel was deleted
      Logs: ${logUrl}
    `));
  });
};
github Dragory / modmailbot / src / data / attachments.js View on Github external
async function saveDiscordAttachment(attachment) {
  if (attachment.size > 1024 * 1024 * 8) {
    return getErrorResult('attachment too large (max 8MB)');
  }

  const attachmentChannelId = config.attachmentStorageChannelId;
  const inboxGuild = utils.getInboxGuild();

  if (! inboxGuild.channels.has(attachmentChannelId)) {
    throw new Error('Attachment storage channel not found!');
  }

  const attachmentChannel = inboxGuild.channels.get(attachmentChannelId);
  if (! (attachmentChannel instanceof Eris.TextChannel)) {
    throw new Error('Attachment storage channel must be a text channel!');
  }

  const file = await attachmentToDiscordFileObject(attachment);
  const savedAttachment = await createDiscordAttachmentMessage(attachmentChannel, file);
  if (! savedAttachment) return getErrorResult();

  return { url: savedAttachment.url };
}
github Yahweasel / craig / craig / eris-flavor.js View on Github external
odf(esp, "broadcastEval", function (cmd) {
        return new Promise((res, rej) => {
            process.send({"_sEval": cmd});

            function receiver(msg) {
                if (msg._sEval === cmd)
                    res(msg._result);
                else
                    process.once("message", receiver);
            }
            process.once("message", receiver);
        });
    });
})(Eris.Shard.prototype);

Eris.TextChannel.prototype.send = Eris.TextChannel.prototype.createMessage;

odf(Eris.User.prototype, "send", function () {
    const args = arguments;
    const user = this;
    return new Promise((res, rej) => {
        user.getDMChannel().then((channel) => {
            channel.createMessage.apply(channel, args).then(res).catch(rej);
        }).catch(rej);
    });
});

odg(Eris.VoiceChannel.prototype, "joinable", function(){return this.permissionsOf(this.guild.shard.client.user.id).has("voiceConnect");});
odg(Eris.VoiceChannel.prototype, "members", function(){return this.voiceMembers;});

odg(Eris.VoiceConnection.prototype, "channel", function () {
    var ret = this.flavorSavedChannel;