added direct message retrieval
This commit is contained in:
parent
5ce1841cba
commit
03a7851605
1 changed files with 24 additions and 6 deletions
30
src/index.js
30
src/index.js
|
@ -1,20 +1,22 @@
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
const {
|
const {
|
||||||
Client,
|
Client,
|
||||||
IntentsBitField,
|
|
||||||
EmbedBuilder,
|
|
||||||
Collection,
|
Collection,
|
||||||
|
GatewayIntentBits,
|
||||||
|
Partials,
|
||||||
} = require("discord.js");
|
} = require("discord.js");
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
IntentsBitField.Flags.Guilds,
|
GatewayIntentBits.Guilds,
|
||||||
IntentsBitField.Flags.GuildMembers,
|
GatewayIntentBits.GuildMembers,
|
||||||
IntentsBitField.Flags.GuildMessages,
|
GatewayIntentBits.GuildMessages,
|
||||||
IntentsBitField.Flags.MessageContent,
|
GatewayIntentBits.MessageContent,
|
||||||
|
GatewayIntentBits.DirectMessages,
|
||||||
],
|
],
|
||||||
|
partials: [Partials.Message, Partials.Channel],
|
||||||
});
|
});
|
||||||
|
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
|
@ -36,6 +38,7 @@ client.on("ready", (c) => {
|
||||||
const channel = client.channels.cache.get("1148814162273763418");
|
const channel = client.channels.cache.get("1148814162273763418");
|
||||||
channel.send("pepperbot restart complete");
|
channel.send("pepperbot restart complete");
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("guildMemberAdd", (member) => {
|
client.on("guildMemberAdd", (member) => {
|
||||||
if (member.guild.id === "1112819622505365556") {
|
if (member.guild.id === "1112819622505365556") {
|
||||||
fs.appendFileSync(
|
fs.appendFileSync(
|
||||||
|
@ -84,6 +87,21 @@ client.on("messageDelete", async (message) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("messageCreate", async (message) => {
|
client.on("messageCreate", async (message) => {
|
||||||
|
if (message.channel.type === 1) {
|
||||||
|
fs.appendFileSync(
|
||||||
|
"../pepperbot/src/logs/directmessages.log",
|
||||||
|
"direct message from: " +
|
||||||
|
message.author.username +
|
||||||
|
"(" +
|
||||||
|
message.author +
|
||||||
|
") at " +
|
||||||
|
Date() +
|
||||||
|
' with: "' +
|
||||||
|
message.content +
|
||||||
|
'"\n'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!message.content.startsWith(prefix)) return;
|
if (!message.content.startsWith(prefix)) return;
|
||||||
const args = message.content.slice(prefix.length).split(/ +/);
|
const args = message.content.slice(prefix.length).split(/ +/);
|
||||||
const command = args.shift().toLowerCase();
|
const command = args.shift().toLowerCase();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue