mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-02 00:31:27 +03:00
do stuff
This commit is contained in:
@@ -125,6 +125,14 @@ module.exports = async (log) => {
|
||||
type: DataTypes.CHAR(18),
|
||||
allowNull: false,
|
||||
},
|
||||
edited: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
},
|
||||
deleted: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
},
|
||||
updates: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
@@ -132,72 +140,6 @@ module.exports = async (log) => {
|
||||
tableName: DB_TABLE_PREFIX + 'messages'
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Channel = sequelize.define('Channel', {
|
||||
id: {
|
||||
type: DataTypes.CHAR(18),
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
tableName: DB_TABLE_PREFIX + 'channel_entities'
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Role = sequelize.define('Role', {
|
||||
id: {
|
||||
type: DataTypes.CHAR(18),
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
colour: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 7506394
|
||||
},
|
||||
}, {
|
||||
tableName: DB_TABLE_PREFIX + 'role_entities'
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Member = sequelize.define('Member', {
|
||||
id: {
|
||||
type: DataTypes.CHAR(18),
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
username: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
discriminator: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
nickname: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
avatar: {
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
colour: {
|
||||
type: DataTypes.INTEGER,
|
||||
},
|
||||
bot: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
},
|
||||
}, {
|
||||
tableName: DB_TABLE_PREFIX + 'member_entities'
|
||||
});
|
||||
|
||||
sequelize.sync();
|
||||
|
||||
return sequelize;
|
||||
|
@@ -2,18 +2,30 @@ module.exports = {
|
||||
event: 'message',
|
||||
execute: async (client, message) => {
|
||||
|
||||
let settings = await message.guild.settings;
|
||||
let settings = await message.guild?.settings;
|
||||
|
||||
if (settings.log_messages) {
|
||||
if (message.type !== 'DEFAULT') return;
|
||||
if (settings?.log_messages) {
|
||||
if (message.system) return;
|
||||
|
||||
let ticket = await client.tickets.get(message.channel.id);
|
||||
let ticket = await client.db.models.Ticket.findOne({
|
||||
where: {
|
||||
id: message.channel.id
|
||||
}
|
||||
});
|
||||
|
||||
if (ticket) {
|
||||
client.db.models.Message.create({
|
||||
await client.db.models.Message.create({
|
||||
id: message.id,
|
||||
ticket: ticket.id,
|
||||
author: message.author.id
|
||||
author: message.author.id,
|
||||
updates: [{
|
||||
content: message.content,
|
||||
time: message.createdTimestamp,
|
||||
embeds: message.embeds.map(embed => {
|
||||
return { ...message.embeds[embed] };
|
||||
}),
|
||||
attachments: [ ...message.attachments.values() ]
|
||||
}]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
29
src/listeners/messageDelete.js
Normal file
29
src/listeners/messageDelete.js
Normal file
@@ -0,0 +1,29 @@
|
||||
module.exports = {
|
||||
event: 'messageDelete',
|
||||
execute: async (client, message) => {
|
||||
|
||||
if (message.partial)
|
||||
try {
|
||||
await message.fetch();
|
||||
} catch (err) {
|
||||
return client.log.error(err);
|
||||
}
|
||||
|
||||
let settings = await message.guild?.settings;
|
||||
|
||||
if (settings?.log_messages) {
|
||||
if (message.system) return;
|
||||
|
||||
let msg = await client.db.models.Message.findOne({
|
||||
where: {
|
||||
id: message.channel.id
|
||||
}
|
||||
});
|
||||
|
||||
if (msg) {
|
||||
msg.deleted = true;
|
||||
await msg.save(); // save changes to message row
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,5 +1,45 @@
|
||||
module.exports = {
|
||||
event: 'messageUpdate',
|
||||
execute: (client, m1, m2) => {
|
||||
event: 'msgUpdate',
|
||||
execute: async (client, oldm, newm) => {
|
||||
|
||||
if (newm.partial)
|
||||
try {
|
||||
await newm.fetch();
|
||||
} catch (err) {
|
||||
return client.log.error(err);
|
||||
}
|
||||
|
||||
let settings = await newm.guild?.settings;
|
||||
|
||||
if (settings?.messages) {
|
||||
if (newm.system) return;
|
||||
|
||||
let msg = await client.db.models.msg.findOne({
|
||||
where: {
|
||||
id: newm.channel.id
|
||||
}
|
||||
});
|
||||
|
||||
if (msg) {
|
||||
let embeds = msg.embeds.map(embed => {
|
||||
return { ...msg.embeds[embed] };
|
||||
});
|
||||
|
||||
if (msg.editedTimestamp) { // message has been edited
|
||||
msg.updates.unshift({
|
||||
content: msg.content,
|
||||
time: msg.editedTimestamp,
|
||||
embeds,
|
||||
attachments: [ ...msg.attachments.values() ]
|
||||
});
|
||||
msg.edited = true;
|
||||
}
|
||||
else { // probably just a link embed loading
|
||||
msg.updates[0] = Object.assign(msg.updates[0], embeds);
|
||||
}
|
||||
|
||||
await msg.save(); // save changes to msg row
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
7
src/listeners/rateLimit.js
Normal file
7
src/listeners/rateLimit.js
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
event: 'rateLimit',
|
||||
execute: (client, limit) => {
|
||||
client.log.warn('Rate-limited!');
|
||||
client.log.debug(limit);
|
||||
}
|
||||
};
|
6
src/listeners/warn.js
Normal file
6
src/listeners/warn.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
event: 'warn',
|
||||
execute: (client, warning) => {
|
||||
client.log.warn(warning);
|
||||
}
|
||||
};
|
@@ -174,8 +174,9 @@ module.exports = class Command {
|
||||
* @param {boolean} secret - Ephemeral message? **NOTE: EMBEDS AND ATTACHMENTS DO NOT RENDER IF TRUE**
|
||||
*/
|
||||
async sendResponse(interaction, content, secret) {
|
||||
const send = this.client.api.interactions(interaction.id, interaction.token).messages['@original'].patch;
|
||||
if (typeof content === 'object')
|
||||
this.client.api.interactions(interaction.id, interaction.token).callback.post({
|
||||
send({
|
||||
data: {
|
||||
type: 4,
|
||||
data: {
|
||||
@@ -184,8 +185,8 @@ module.exports = class Command {
|
||||
}
|
||||
}
|
||||
});
|
||||
else
|
||||
this.client.api.interactions(interaction.id, interaction.token).callback.post({
|
||||
else if (typeof content === 'string')
|
||||
send({
|
||||
data: {
|
||||
type: 4,
|
||||
data: {
|
||||
|
@@ -1,4 +1,26 @@
|
||||
module.exports = {
|
||||
TicketManager: require('./manager'),
|
||||
Ticket: require('./ticket'),
|
||||
const EventEmitter = require('events');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { Client } = require('discord.js');
|
||||
|
||||
/** Manages tickets */
|
||||
module.exports = class extends EventEmitter {
|
||||
/**
|
||||
* Create a TicketManager instance
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super();
|
||||
|
||||
/** The Discord Client */
|
||||
this.client = client;
|
||||
|
||||
this.setMaxListeners(this.client.config.max_listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ticket
|
||||
*/
|
||||
async create() {
|
||||
|
||||
}
|
||||
};
|
@@ -1,26 +0,0 @@
|
||||
const EventEmitter = require('events');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { Client } = require('discord.js');
|
||||
|
||||
/** Manages tickets */
|
||||
module.exports = class extends EventEmitter {
|
||||
/**
|
||||
* Create a TicketManager instance
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super();
|
||||
|
||||
/** The Discord Client */
|
||||
this.client = client;
|
||||
|
||||
this.setMaxListeners(this.client.config.max_listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ticket
|
||||
*/
|
||||
async create() {
|
||||
|
||||
}
|
||||
};
|
@@ -25,15 +25,6 @@ module.exports = {
|
||||
*/
|
||||
flags: (secret) => secret ? 1 << 64 : undefined,
|
||||
|
||||
/**
|
||||
* Set message entities
|
||||
* @param {Discord.Message} message - The message to set entities for
|
||||
*/
|
||||
|
||||
messageEntities(message) {
|
||||
const { client } = message;
|
||||
},
|
||||
|
||||
/**
|
||||
* Select a presence from the config
|
||||
* @returns {Discord.PresenceData}
|
||||
|
Reference in New Issue
Block a user