Skip to content

Commit

Permalink
add additional logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsundso committed Dec 19, 2023
1 parent 8d8f292 commit 5dd23e8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
2 changes: 2 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ model guildsettings {
editrpcommands Boolean @db.Boolean @default(true)
lan String @db.Text @default("en-GB")
errorchannel String? @db.VarChar
statuschannel String? @db.VarChar
updateschannel String? @db.Text
enabledrp Boolean @db.Boolean @default(false)
rpenableruns Decimal @db.Decimal @default(0)
lastrpsyncrun Decimal? @db.Decimal
Expand Down
2 changes: 2 additions & 0 deletions src/BaseClient/Other/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@ export default {
editrpcommands: 'boolean',
lan: 'language',
errorchannel: 'channel',
statuschannel: 'channel',
updateschannel: 'channel',
vanity: 'string',
ptreminderenabled: 'boolean',
token: 'bot-token',
Expand Down
65 changes: 57 additions & 8 deletions src/Commands/SlashCommands/settings/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ export const getEmbeds: CT.SettingsFile<typeof name>['getEmbeds'] = async (
: language.languages['en-GB'],
inline: true,
},
{
name: lan.fields.errorchannel.name,
value: embedParsers.channel(settings?.errorchannel, language),
inline: true,
},
{
name: lan.fields.token.name,
value: settings.token
Expand All @@ -121,6 +116,26 @@ export const getEmbeds: CT.SettingsFile<typeof name>['getEmbeds'] = async (
)})`
: language.t.None,
},
{
name: '\u200b',
value: '\u200b',
inline: false,
},
{
name: lan.fields.errorchannel.name,
value: embedParsers.channel(settings?.errorchannel, language),
inline: true,
},
{
name: lan.fields.statuschannel.name,
value: embedParsers.channel(settings?.statuschannel, language),
inline: true,
},
{
name: lan.fields.updateschannel.name,
value: embedParsers.channel(settings?.updateschannel, language),
inline: true,
},
],
},
];
Expand Down Expand Up @@ -188,6 +203,40 @@ export const postChange: CT.SettingsFile<typeof name>['postChange'] = async (
if (!newSettings) return;

switch (changedSetting) {
case 'statuschannel': {
if (!newSettings.statuschannel) break;

const channel = await ch.getChannel.guildTextChannel(newSettings.statuschannel);
if (!channel) break;

const response = await ch.request.channels.followAnnouncements(channel, '827312892982198272');
if (!('message' in response)) return;

ch.error(
guild,
new Error(
'Could not follow channel. Please adjust permissions as outlined above and re-set the channel',
),
);
break;
}
case 'updateschannel': {
if (!newSettings.updateschannel) break;

const channel = await ch.getChannel.guildTextChannel(newSettings.updateschannel);
if (!channel) break;

const response = await ch.request.channels.followAnnouncements(channel, '765743834118225961');
if (!('message' in response)) return;

ch.error(
guild,
new Error(
'Could not follow channel. Please adjust permissions as outlined above and re-set the channel',
),
);
break;
}
case 'token': {
if (!newSettings.token) {
ch.cache.apis.delete(guild.id);
Expand All @@ -198,7 +247,7 @@ export const postChange: CT.SettingsFile<typeof name>['postChange'] = async (

ch.request.commands.getGuildCommands(guild);
ch.cache.commandPermissions.get(guild, '');
return;
break;
}

requestHandler(guild.id, newSettings.token);
Expand All @@ -220,15 +269,15 @@ export const postChange: CT.SettingsFile<typeof name>['postChange'] = async (
})
.then();

return;
break;
}

if (!me.bot_public) {
ch.error(
guild,
new Error('Bot is not public, please make it public so it can use external Emojis'),
);
return;
break;
}

ch.send(
Expand Down

0 comments on commit 5dd23e8

Please sign in to comment.