Direct message support
This commit is contained in:
parent
d51d400e04
commit
e94140a205
29
src/index.js
29
src/index.js
@ -1,4 +1,4 @@
|
|||||||
import { Client, GatewayIntentBits, REST, Routes } from 'discord.js';
|
import { Client, GatewayIntentBits, Partials, REST, Routes } from 'discord.js';
|
||||||
import * as dotenv from 'dotenv'
|
import * as dotenv from 'dotenv'
|
||||||
import constants from './constants.js';
|
import constants from './constants.js';
|
||||||
import { ClassicLevel } from 'classic-level';
|
import { ClassicLevel } from 'classic-level';
|
||||||
@ -333,6 +333,7 @@ const openResponses = (interaction, ephemeral) => async content =>
|
|||||||
addSubcommands({
|
addSubcommands({
|
||||||
name: 'macro',
|
name: 'macro',
|
||||||
description: "Manage macros",
|
description: "Manage macros",
|
||||||
|
'dm_permission': false,
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'add',
|
name: 'add',
|
||||||
@ -429,16 +430,26 @@ addSubcommands({
|
|||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
GatewayIntentBits.Guilds,
|
GatewayIntentBits.Guilds,
|
||||||
GatewayIntentBits.GuildMessages,
|
GatewayIntentBits.GuildMessages,
|
||||||
GatewayIntentBits.MessageContent,
|
GatewayIntentBits.MessageContent,
|
||||||
GatewayIntentBits.DirectMessages
|
GatewayIntentBits.DirectMessages
|
||||||
|
],
|
||||||
|
partials: [
|
||||||
|
Partials.Channel
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const safeSubscribe = (event, callback) => {
|
||||||
|
client.on(event, (...args) => {
|
||||||
|
return callback(...args)
|
||||||
|
.catch(err => console.error(err))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const rest = new REST().setToken(process.env.DISCORD_TOKEN)
|
const rest = new REST().setToken(process.env.DISCORD_TOKEN)
|
||||||
|
|
||||||
client.on('ready', async () => {
|
safeSubscribe('ready', async () => {
|
||||||
console.log("Logged in!")
|
console.log("Logged in!")
|
||||||
|
|
||||||
let guildIds = await pruneDB()
|
let guildIds = await pruneDB()
|
||||||
@ -449,9 +460,9 @@ client.on('ready', async () => {
|
|||||||
console.log("Ready")
|
console.log("Ready")
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('messageCreate', messageCycle)
|
safeSubscribe('messageCreate', messageCycle)
|
||||||
|
|
||||||
client.on('messageUpdate', async (oldMessage, newMessage) => {
|
safeSubscribe('messageUpdate', async (oldMessage, newMessage) => {
|
||||||
if(replies.has(newMessage.id) ) {
|
if(replies.has(newMessage.id) ) {
|
||||||
let { id } = replies.get(newMessage.id)
|
let { id } = replies.get(newMessage.id)
|
||||||
|
|
||||||
@ -519,7 +530,7 @@ const handleAutocomplete = async interaction => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.on('interactionCreate', interaction => {
|
safeSubscribe('interactionCreate', interaction => {
|
||||||
if(interaction.isChatInputCommand()) {
|
if(interaction.isChatInputCommand()) {
|
||||||
return handleCommand(interaction)
|
return handleCommand(interaction)
|
||||||
} else if(interaction.isAutocomplete()) {
|
} else if(interaction.isAutocomplete()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user