Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// There's no good way to simulate this
const guild = this;
this.fetchAllMembers();
return new Promise((res, rej) => {
setTimeout(()=>{res(guild);}, 1000);
});
});
odg(egp, "voiceConnection", function(){return this.shard.client.voiceConnections.get(this.id);});
})(Eris.Guild.prototype);
odg(Eris.Member.prototype, "voiceChannel", function(){return this.voiceState.channelID?(this.guild.channels.get(this.voiceState.channelID)):undefined;});
odg(Eris.Message.prototype, "guild", function(){return this.channel.guild;});
odf(Eris.Message.prototype, "reply", function(content){return this.channel.send(this.author.mention + ", " + content);});
Eris.PrivateChannel.prototype.send = Eris.PrivateChannel.prototype.createMessage;
odg(Eris.Role.prototype, "members", function () {
const role = this;
return this.guild.members.filter((member) => {
return member.roles.includes(role.id);
});
});
(function (esp) {
odf(esp, "send", function(){return process.send.apply(process, arguments);});
odf(esp, "broadcastEval", function (cmd) {
return new Promise((res, rej) => {
process.send({"_sEval": cmd});
function receiver(msg) {
if (msg._sEval === cmd)
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;
bot.on('messageCreate', (msg) => {
if (! (msg.channel instanceof Eris.PrivateChannel)) return;
if (msg.author.id === bot.user.id) return;
if (blocked.indexOf(msg.author.id) !== -1) return;
// This needs to be queued as otherwise, if a user sent a bunch of messages initially and the createChannel endpoint is delayed, we might get duplicate channels
messageQueue.add(() => {
return getModmailChannel(msg.author).then(channel => {
channel.createMessage(`« **${msg.author.username}#${msg.author.discriminator}:** ${msg.content}`);
if (channel._wasCreated) {
bot.createMessage(modMailGuild.id, {
content: `@here New modmail thread: ${channel.mention}`,
disableEveryone: false,
});
msg.channel.createMessage("Thank you for your message! Our mod team will reply to you here as soon as possible.");
bot.on('messageUpdate', async (msg, oldMessage) => {
if (! msg || ! msg.author) return;
if (msg.author.bot) return;
if (await blocked.isBlocked(msg.author.id)) return;
// Old message content doesn't persist between bot restarts
const oldContent = oldMessage && oldMessage.content || '*Unavailable due to bot restart*';
const newContent = msg.content;
// Ignore bogus edit events with no changes
if (newContent.trim() === oldContent.trim()) return;
// 1) Edit in DMs
if (msg.channel instanceof Eris.PrivateChannel) {
const thread = await threads.findOpenThreadByUserId(msg.author.id);
if (! thread) return;
const editMessage = utils.disableLinkPreviews(`**The user edited their message:**\n\`B:\` ${oldContent}\n\`A:\` ${newContent}`);
thread.postSystemMessage(editMessage);
}
// 2) Edit in the thread
else if (utils.messageIsOnInboxServer(msg) && utils.isStaff(msg.member)) {
const thread = await threads.findOpenThreadByChannelId(msg.channel.id);
if (! thread) return;
thread.updateChatMessage(msg);
}
});
bot.on('messageCreate', async msg => {
if (! (msg.channel instanceof Eris.PrivateChannel)) return;
if (msg.author.bot) return;
if (msg.type !== 0) return; // Ignore pins etc.
if (await blocked.isBlocked(msg.author.id)) return;
// Private message handling is queued so e.g. multiple message in quick succession don't result in multiple channels being created
messageQueue.add(async () => {
let thread = await threads.findOpenThreadByUserId(msg.author.id);
// New thread
if (! thread) {
// Ignore messages that shouldn't usually open new threads, such as "ok", "thanks", etc.
if (config.ignoreAccidentalThreads && msg.content && ACCIDENTAL_THREAD_MESSAGES.includes(msg.content.trim().toLowerCase())) return;
thread = await threads.createNewThreadForUser(msg.author);
}
commands.addGlobalCommand('close', '[opts...]', async (msg, args) => {
let thread, closedBy;
let hasCloseMessage = !! config.closeMessage;
let silentClose = false;
if (msg.channel instanceof Eris.PrivateChannel) {
// User is closing the thread by themselves (if enabled)
if (! config.allowUserClose) return;
if (await blocked.isBlocked(msg.author.id)) return;
thread = await threads.findOpenThreadByUserId(msg.author.id);
if (! thread) return;
// We need to add this operation to the message queue so we don't get a race condition
// between showing the close command in the thread and closing the thread
await messageQueue.add(async () => {
thread.postSystemMessage('Thread closed by user, closing...');
await thread.close(true);
});
closedBy = 'the user';
} else {
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
}