Fix DMs and Group DMs.
This commit is contained in:
parent
96df07b735
commit
f20ee7690f
27
index.js
27
index.js
@ -10,6 +10,8 @@ client.on("ready", async () => {
|
||||
|
||||
let savedMessage;
|
||||
let count = 0;
|
||||
const shapeGuild = config.shapeGuild;
|
||||
const ALLOWED_CHANNEL_TYPES = ["DM", "GROUP_DM"];
|
||||
|
||||
function isAllowedUser(id) {
|
||||
if (config.ALLOWED_IDS.find(string => string == id)) return true;
|
||||
@ -51,24 +53,33 @@ async function getMessageContent(message) {
|
||||
}
|
||||
}
|
||||
|
||||
client.on("messageCreate", async function(message){
|
||||
try {
|
||||
let shapeGuild = config.shapeGuild
|
||||
async function sendToAI(message) {
|
||||
if (message.author.id == client.user.id) return;
|
||||
savedMessage = message;
|
||||
client.guilds.cache.get(shapeGuild).channels.cache.get(config.shapeChannel).send(await getMessageContent(message));
|
||||
}
|
||||
|
||||
async function processGuildTextMessage(message) {
|
||||
if (message.author.id == config.admin && message.content.startsWith("e ")) {
|
||||
eval(message.content.substring(1));
|
||||
}
|
||||
else if (message.guild.id != shapeGuild && (message.author.id != client.user.id && (message.mentions.users.get(client.user.id) || isAllowedUser(message.author.id) || (!isAllowedUser && count % 5 == 0) || (message.reference && message.channel.messages.cache.get(message.reference.messageId).author.id == client.user.id)))) {
|
||||
savedMessage = message;
|
||||
client.guilds.cache.get(shapeGuild).channels.cache.get(config.shapeChannel).send(await getMessageContent(message));
|
||||
}
|
||||
else if (message.guild.id != shapeGuild &&
|
||||
(message.mentions.users.get(client.user.id) || isAllowedUser(message.author.id) || (!isAllowedUser && count % 5 == 0)
|
||||
|| (message.reference && message.channel.messages.cache.get(message.reference.messageId).author.id == client.user.id)))
|
||||
sendToAI(message);
|
||||
else if (message.guild.id == shapeGuild && message.author.bot && savedMessage) {
|
||||
savedMessage.channel.sendTyping();
|
||||
savedMessage.channel.send("<@" + savedMessage.author.id + "> " + message.content);
|
||||
}
|
||||
if (!isAllowedUser(message.author.id)) count++;
|
||||
}
|
||||
|
||||
client.on("messageCreate", function(message){
|
||||
try {
|
||||
if (message.channel.type == "GUILD_TEXT") processGuildTextMessage(message);
|
||||
else if (ALLOWED_CHANNEL_TYPES.find(type => type == message.channel.type)) sendToAI(message);
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(config.token);
|
Loading…
Reference in New Issue
Block a user