Skip to content

Commit

Permalink
new formatting, bot messages will be ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldietzler committed Oct 9, 2023
1 parent acbec63 commit 4f45dfa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/events/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GITHUB_API_DOMAIN, GITHUB_DOMAIN } from '../constants.js';
export class Messages {
@On({ event: 'messageCreate' })
async newMessage([message]: ArgsOf<'messageCreate'>) {
if (message.author.id === '1158729698872930445') {
if (message.author.bot) {
return;
}

Expand All @@ -27,13 +27,13 @@ export class Messages {
if (response.status === 200) {
const json = await response.json();
const type = json.pull_request ? 'PR' : 'ISSUE';
links.push(`[[${type}] ${json.title} (#${id})](${json.html_url})`);
links.push(`[${type}] ${json.title} ([#${id}](${json.html_url}))`);
continue;
}

const { status: discussionStatus } = await fetch(`${GITHUB_DOMAIN}/discussions/${id}}`);
if (discussionStatus === 200) {
links.push(`[[Discussion] (#${id})](${GITHUB_DOMAIN}/discussions/${id})`);
links.push(`[Discussion] ([#${id}](${GITHUB_DOMAIN}/discussions/${id}))`);
}
}
}
Expand All @@ -42,6 +42,10 @@ export class Messages {

@On({ event: 'messageCreate' })
preventGithubEmbeddings([message]: ArgsOf<'messageCreate'>) {
if (message.author.bot) {
return;
}

if (message.embeds.find((embed) => embed.url?.startsWith(GITHUB_DOMAIN))) {
message.suppressEmbeds(true);
}
Expand Down

0 comments on commit 4f45dfa

Please sign in to comment.