How to use the eris.GuildChannel 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 Geo1088 / yuuko / src / Command.ts View on Github external
async function fulfillsRequirements (requirements: CommandRequirements, msg: Eris.Message, args: string[], ctx: CommandContext) {
	const {owner, permissions, custom} = requirements;
	const {client} = ctx;
	// Owner checking
	if (owner && client.app && client.app.owner.id !== msg.author.id) {
		return false;
	}
	// Permissions
	if (permissions && permissions.length > 0) {
		// If we require permissions, the command can't be used in direct
		// messages
		if (!(msg.channel instanceof Eris.GuildChannel)) {
			return false;
		}
		// Calculate permissions of the user and check all we need
		const memberPerms = msg.channel.permissionsOf(msg.author.id);
		for (const permission of permissions) {
			if (!memberPerms.has(permission)) {
				return false;
			}
		}
	}
	// Custom requirement function
	if (custom && !await custom(msg, args, ctx)) {
		return false;
	}
	// If we haven't returned yet, all requirements are met
	return true;
github Dragory / modmailbot / src / modules / typingProxy.js View on Github external
bot.on("typingStart", async (channel, user) => {
      // config.typingProxy: forward user typing in a DM to the modmail thread
      if (config.typingProxy && (channel instanceof Eris.PrivateChannel)) {
        const thread = await threads.findOpenThreadByUserId(user.id);
        if (! thread) return;

        try {
          await bot.sendChannelTyping(thread.channel_id);
        } catch (e) {}
      }

      // config.typingProxyReverse: forward moderator typing in a thread to the DM
      else if (config.typingProxyReverse && (channel instanceof Eris.GuildChannel) && ! user.bot) {
        const thread = await threads.findByChannelId(channel.id);
        if (! thread) return;

        const dmChannel = await thread.getDMChannel();
        if (! dmChannel) return;

        try {
          await bot.sendChannelTyping(dmChannel.id);
        } catch(e) {}
      }
    });
  }
github Geo1088 / yuuko / src / Client.ts View on Github external
// Traditional prefix checking
		for (const prefix of prefixes) {
			if (this.caseSensitivePrefix ? msg.content.startsWith(prefix) : msg.content.toLowerCase().startsWith(prefix.toLowerCase())) {
				return [prefix, msg.content.substr(prefix.length)];
			}
		}
		// Allow mentions to be used as prefixes according to config
		if (this.allowMention) {
			const match = msg.content.match(this.mentionPrefixRegExp!);
			if (match) { // TODO: guild config
				return [match[0], msg.content.substr(match[0].length)];
			}
		}
		// Allow no prefix in direct message channels
		if (!(msg.channel instanceof Eris.GuildChannel)) {
			return ['', msg.content];
		}
		// we got nothing
		return null;
	}
github macdja38 / pvpcraft / lib / MessageSender.js View on Github external
}).catch((e) => {
        console.log(e);
        if (!(calledOptions.channel instanceof Eris.GuildChannel)) return;
        let texts;
        if (queue.length > 1) {
          texts = queue.slice(1).reduce((prev, cur) => `${prev.text}\n${cur.text}`, calledOptions).match(/^.{1,1900}/g);
        } else {
          texts = calledOptions.text.match(/^.{1,1900}/g);
        }
        texts.forEach((string) => {
          calledOptions.channel.createMessage(this.i10010n(this.getChannelLanguage(calledOptions.channel.id)) `${string}\nPlease give the bot \"Manage Webhooks\" to enable non fallback functionality`).catch(() => {});
        });
      })
    }
github macdja38 / pvpcraft / PvPCraft.js View on Github external
checkChannelAllowed(channel, allowed) {
    if (allowed.includes("*")) return true;
    if (channel instanceof Eris.GuildChannel && allowed.includes("guild")) return true;
    if (channel instanceof Eris.PrivateChannel && allowed.includes("dm")) return true;
    return false
  }