mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-12 19:56:06 -05:00
* Add: skeleton suite for command tests (#119) * test naming updated * fix imports, remove old references * added code coverage badge * Add: coverage environment * Fix: Readme hyperlink to coverage workflow * grab coverage pct from env * Update: gist hyperlink * color range on coverage * fix contributing, simplify coverage assessment * lmiit coverage to master, add branch naming conventions --------- Co-authored-by: Kevin Dang <77701718+kevinthedang@users.noreply.github.com>
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import { ChannelType, Client, CommandInteraction, TextChannel } from 'discord.js'
|
|
import { clearChannelInfo, SlashCommand } from '../utils/index.js'
|
|
|
|
export const ClearUserChannelHistory: SlashCommand = {
|
|
name: 'clear-user-channel-history',
|
|
description: 'clears history for user running this command in current channel',
|
|
|
|
// Clear channel history for intended user
|
|
run: async (client: Client, interaction: CommandInteraction) => {
|
|
// fetch current channel
|
|
const channel = await client.channels.fetch(interaction.channelId)
|
|
|
|
// if not an existing channel or a GuildText, fail command
|
|
if (!channel || channel.type !== ChannelType.GuildText) return
|
|
|
|
// clear channel info for user
|
|
const successfulWipe = await clearChannelInfo(interaction.channelId,
|
|
interaction.channel as TextChannel,
|
|
interaction.user.username)
|
|
|
|
// check result of clearing history
|
|
if (successfulWipe)
|
|
interaction.reply({
|
|
content: `Channel history in **${channel.name}** cleared for **${interaction.user.username}**.`,
|
|
ephemeral: true
|
|
})
|
|
else
|
|
interaction.reply({
|
|
content: `Channel history could not be found for **${interaction.user.username}** in **${channel.name}**.\n\nPlease chat with **${client.user?.username}** to start a chat history.`,
|
|
ephemeral: true
|
|
})
|
|
}
|
|
} |