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 .env.local
eslint_report.json eslint_report.json
.DS_Store

View file

@ -18,7 +18,7 @@ import { tagsCommand } from './commands/tags';
import { jokeCommand } from './commands/joke'; import { jokeCommand } from './commands/joke';
import random from 'just-random'; import random from 'just-random';
import { green, bold, yellow } from 'kleur/colors'; import { green, bold, yellow, cyan } from 'kleur/colors';
import 'dotenv/config'; import 'dotenv/config';
const client = new Client({ const client = new Client({
@ -39,26 +39,28 @@ client.once('ready', async () => {
console.log(green('Discord bot ready!')); console.log(green('Discord bot ready!'));
console.log( console.log(
client.generateInvite({ cyan(
scopes: [OAuth2Scopes.Bot], client.generateInvite({
permissions: [ scopes: [OAuth2Scopes.Bot],
'AddReactions', permissions: [
'ViewChannel', 'AddReactions',
'BanMembers', 'ViewChannel',
'KickMembers', 'BanMembers',
'CreatePublicThreads', 'KickMembers',
'CreatePrivateThreads', 'CreatePublicThreads',
'EmbedLinks', 'CreatePrivateThreads',
'ManageChannels', 'EmbedLinks',
'ManageRoles', 'ManageChannels',
'ModerateMembers', 'ManageRoles',
'MentionEveryone', 'ModerateMembers',
'MuteMembers', 'MentionEveryone',
'SendMessages', 'MuteMembers',
'SendMessagesInThreads', 'SendMessages',
'ReadMessageHistory', 'SendMessagesInThreads',
], 'ReadMessageHistory',
}) ],
})
)
); );
if (process.env.NODE_ENV !== 'development') if (process.env.NODE_ENV !== 'development')
@ -71,6 +73,9 @@ client.once('ready', async () => {
}); });
client.on('messageCreate', async (e) => { 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.content) return;
if (!e.channel.isTextBased()) return; if (!e.channel.isTextBased()) return;

View file

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