fix: trim tags

This commit is contained in:
Ryan Cao 2022-11-12 21:52:40 +08:00
parent 4e2afcc7f8
commit fcb37570ae
No known key found for this signature in database
3 changed files with 30 additions and 23 deletions

2
.gitignore vendored
View file

@ -7,3 +7,5 @@ dist
.env.local
eslint_report.json
.DS_Store

View file

@ -18,7 +18,7 @@ import { tagsCommand } from './commands/tags';
import { jokeCommand } from './commands/joke';
import random from 'just-random';
import { green, bold, yellow } from 'kleur/colors';
import { green, bold, yellow, cyan } from 'kleur/colors';
import 'dotenv/config';
const client = new Client({
@ -39,6 +39,7 @@ client.once('ready', async () => {
console.log(green('Discord bot ready!'));
console.log(
cyan(
client.generateInvite({
scopes: [OAuth2Scopes.Bot],
permissions: [
@ -59,6 +60,7 @@ client.once('ready', async () => {
'ReadMessageHistory',
],
})
)
);
if (process.env.NODE_ENV !== 'development')
@ -71,6 +73,9 @@ client.once('ready', async () => {
});
client.on('messageCreate', async (e) => {
if (e.channel.partial) await e.channel.fetch();
if (e.author.partial) await e.author.fetch();
if (!e.content) return;
if (!e.channel.isTextBased()) return;

View file

@ -28,7 +28,7 @@ export const getTags = async (): Promise<Tag[]> => {
name: _file.replace('.md', ''),
embed: {
...data.embed,
description: content,
description: content.trim(),
color: COLORS[data.embed.color],
},
});
@ -36,7 +36,7 @@ export const getTags = async (): Promise<Tag[]> => {
tags.push({
...data,
name: _file.replace('.md', ''),
text: content,
text: content.trim(),
});
}
}