small fixes and add chat timestamp thrw command

This commit is contained in:
The Foxon 2023-07-14 00:42:09 +12:00
parent 9567a875f1
commit fddedac210
3 changed files with 38 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import Message from './Message'
import Exec from './Exec' import Exec from './Exec'
import syncMessages from './syncMessages' import syncMessages from './syncMessages'
import setChatChannelId from './setChatChannelId' import setChatChannelId from './setChatChannelId'
import throwChatTimestamp from './throwChatTimestamp'
const commands = new Collection const commands = new Collection
@ -14,5 +15,6 @@ commands.set(Message.data.name, Message)
commands.set(Exec.data.name, Exec) commands.set(Exec.data.name, Exec)
commands.set(syncMessages.data.name, syncMessages) commands.set(syncMessages.data.name, syncMessages)
commands.set(setChatChannelId.data.name, setChatChannelId) commands.set(setChatChannelId.data.name, setChatChannelId)
commands.set(throwChatTimestamp.data.name, throwChatTimestamp)
export default commands export default commands

View File

@ -0,0 +1,27 @@
import { CacheType, ChatInputCommandInteraction, Message, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
import ConfigManager from '../controller/ConfigManager';
import ChatController from '../controller/ChatController';
import { error } from 'console';
// const adminPermissions = new PermissionsBitField('Administrator');
export default {
data: new SlashCommandBuilder()
.setName('throw_chat_timestamp')
.setDescription('throw chat timestamp')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction: ChatInputCommandInteraction<CacheType>, config: ConfigManager) {
await interaction.deferReply({ ephemeral: true })
try {
global.config.messageTime = 0
await interaction.followUp("Время сброшено")
return
} catch (error) {
await interaction.editReply("Ошибка сброса времени")
console.log(error)
}
},
};

View File

@ -70,14 +70,15 @@ export default class ChatController {
} }
messages.forEach(async m => { messages.forEach(async m => {
if (global.config.messageTime < m.Timestamp) if (global.config.messageTime !== m.Timestamp) {
global.config.messageTime = m.Timestamp if (global.config.messageTime < m.Timestamp)
// const me = new EmbedBuilder() global.config.messageTime = m.Timestamp
// me.setDescription(m.Text) // const me = new EmbedBuilder()
// me.setAuthor({ name: m.Sender }) // me.setDescription(m.Text)
// ch.send({ embeds: [me] }) // me.setAuthor({ name: m.Sender })
console.log(`${m.Sender}: ${m.Text}`) // ch.send({ embeds: [me] })
await ch.send(`**${m.Sender}**: ${m.Text}`) await ch.send(`**${m.Sender}**: ${m.Text}`)
}
}) })
isSyncing = false isSyncing = false