Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #135 #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/modules/check-custom-emojis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,35 @@ export default class extends Module {
}

@bindThis
private async post() {
private async post(byMentionHook:boolean = false) {
this.log('Start to Check CustomEmojis.');
const lastEmoji = this.lastEmoji.find({});

const lastId = lastEmoji.length != 0 ? lastEmoji[0].id : null;
const emojisData = await this.checkCumstomEmojis(lastId);
if (emojisData.length == 0) {
let emojisData:any[] | null = null;
try {
emojisData = await this.checkCumstomEmojis(lastId);
} catch (err: unknown) {
this.log('Error By API(admin/emoji/list)');
if (err instanceof Error) {
this.log(`${err.name}\n${err.message}`);
}
}
if (emojisData === null) {
const errMessage = 'read:admin:emoji権限がないため、エラーが発生しました。\nカスタム絵文字管理の権限が付与されているか見直しをお願いします。';
this.log(errMessage);
await this.ai.post({
text: errMessage
});
return;
}
else if (emojisData.length == 0) {
this.log('No CustomEmojis Added.');
if (byMentionHook) {
await this.ai.post({
text: serifs.checkCustomEmojis.nothing
});
}
return;
}

Expand Down Expand Up @@ -148,7 +169,7 @@ export default class extends Module {
this.log('Check CustomEmojis requested');
}

await this.post();
await this.post(true);

return {
reaction: 'like'
Expand Down
3 changes: 2 additions & 1 deletion src/serifs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ export default {
post: (server_name, num) => `${server_name}に${num}件の絵文字が追加されました!`,
emojiPost: emoji => `:${emoji}:\n(\`${emoji}\`) #AddCustomEmojis`,
postOnce: (server_name, num, text) => `${server_name}に${num}件の絵文字が追加されました!\n${text} #AddCustomEmojis`,
emojiOnce: emoji => `:${emoji}:(\`${emoji}\`)`
emojiOnce: emoji => `:${emoji}:(\`${emoji}\`)`,
nothing: '絵文字を確認しましたが、なにも追加されていないみたいです',
},

sleepReport: {
Expand Down