-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear User Channel History Command (#88)
* Add: Clear user channel message history command * Update: Checks if messages are empty and has clearer replies * Fix: Issue where duplication happens on channel-toggle true in threads * Update: version increment * Fix: Missing test case for commands.test.ts * Readability fix --------- Co-authored-by: Jonathan Smoley <67881240+JT2M0L3Y@users.noreply.github.com>
- Loading branch information
1 parent
e60c2f8
commit 352d88e
Showing
8 changed files
with
99 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ChannelType, Client, CommandInteraction, TextChannel } from 'discord.js' | ||
import { SlashCommand } from '../utils/commands.js' | ||
import { clearChannelInfo } 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 | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters