update
This commit is contained in:
parent
f14cd119a3
commit
ccc2b39563
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
config.json
|
||||||
|
token.txt
|
||||||
|
ban_config.json
|
||||||
|
node_modules
|
38
index.js
38
index.js
@ -7,11 +7,15 @@ const client = new Client({
|
|||||||
GatewayIntentBits.GuildMembers,
|
GatewayIntentBits.GuildMembers,
|
||||||
GatewayIntentBits.GuildPresences,
|
GatewayIntentBits.GuildPresences,
|
||||||
GatewayIntentBits.GuildVoiceStates,
|
GatewayIntentBits.GuildVoiceStates,
|
||||||
GatewayIntentBits.GuildModeration
|
GatewayIntentBits.GuildModeration,
|
||||||
|
GatewayIntentBits.MessageContent,
|
||||||
|
GatewayIntentBits.GuildMessages
|
||||||
],
|
],
|
||||||
|
|
||||||
});
|
});
|
||||||
const config = JSON.parse(readFileSync("config.json", "utf-8"));
|
const config = JSON.parse(readFileSync("config.json", "utf-8"));
|
||||||
|
const banConfig = JSON.parse(readFileSync("ban_config.json", "utf-8"));
|
||||||
|
|
||||||
|
|
||||||
await client.login(readFileSync("token.txt", "utf-8").split("\n")[0]);
|
await client.login(readFileSync("token.txt", "utf-8").split("\n")[0]);
|
||||||
|
|
||||||
@ -91,6 +95,38 @@ client.on(Events.ClientReady, async () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
client.on(Events.MessageCreate, async m => {
|
||||||
|
if (!m.guildId) {
|
||||||
|
console.log("Got non-guild message");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!banConfig[m.guildId]) {
|
||||||
|
console.log("Got message in", m.guildId, "/", m.channelId, "without ban config setup.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let channels = banConfig[m.guildId];
|
||||||
|
if (channels.includes(m.channelId)) {
|
||||||
|
try {
|
||||||
|
const dm = await m.author.createDM();
|
||||||
|
await dm.send("You have been banned for sending a message in the bot trap. Mistake? Appeal here: https://forms.gle/r41Qd12A3Df6kbm56");
|
||||||
|
} catch(e) {
|
||||||
|
console.log("Failed to send message", e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await m.guild.bans.create(m.author, {
|
||||||
|
deleteMessageSeconds: 600,
|
||||||
|
reason: "Caught in a bot trap like a stupid fly in a glue trap."
|
||||||
|
})
|
||||||
|
} catch(e) {
|
||||||
|
console.log("Failed to issue ban", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
|
client.on(Events.VoiceStateUpdate, async (oldState, newState) => {
|
||||||
if (oldState.channelId === newState.channelId) return;
|
if (oldState.channelId === newState.channelId) return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user