Skip to content

Commit

Permalink
fix(bugs): if user not register channel
Browse files Browse the repository at this point in the history
  • Loading branch information
peam1146 committed Aug 16, 2023
1 parent 1998115 commit 5e6ff39
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
DISCORD_TOKEN=
DATABASE_URL="file:foo.db"

GITHUB_TOKEN=
GITHUB_DISPATCH_URL=
Expand Down
4 changes: 4 additions & 0 deletions src/channel/channel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export class ChannelService {
.select('channel_id')
.executeTakeFirst();

if (!channelId) {
throw new Error('Please set the channel first');
}

const chan = this.client.channels.cache.get(channelId);
if (chan.isTextBased()) {
await chan.send(`${packageName} \nfrom <@${userId}>`);
Expand Down
15 changes: 10 additions & 5 deletions src/discord/command/showcase/showcase.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ export class ShowcaseCommand {
from_server: args[0].guild.name,
package_url: dto.package,
});
this.channelService.sendShowcaseMessage(
args[0].guildId,
dto.package,
args[0].user.id,
);

try {
this.channelService.sendShowcaseMessage(
args[0].guildId,
dto.package,
args[0].user.id,
);
} catch (error) {
return 'Please set the channel first';
}
return 'Showcase message was sent!';
}
}

0 comments on commit 5e6ff39

Please sign in to comment.