Skip to content

Commit

Permalink
fix #291
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsundso committed Jan 10, 2025
1 parent 7b52d1a commit 666d4a3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/BaseClient/Other/constants/settingsEditorTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default {
wlchannelid: CT.EditorTypes.Channels,
wlroleid: CT.EditorTypes.Roles,
wluserid: CT.EditorTypes.Users,
pingUser: CT.EditorTypes.Boolean,
},
[CT.SettingNames.MultiChannels]: {
channels: CT.EditorTypes.Channels,
Expand Down
6 changes: 6 additions & 0 deletions src/Commands/SlashCommands/settings/leveling/level-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export const getEmbeds: CT.SettingsFile<typeof name>['getEmbeds'] = async (
value: embedParsers.time(Number(settings.lvlupdeltimeout) * 1000, language),
inline: true,
},
{
name: lan.fields.pingUser.name,
value: embedParsers.boolean(settings.pingUser, language),
inline: true,
},
{
name: lan.fields.lvlupchannels.name,
value: embedParsers.channels(settings.lvlupchannels, language),
Expand Down Expand Up @@ -139,6 +144,7 @@ export const getComponents: CT.SettingsFile<typeof name>['getComponents'] = (
components[1].components.push(
buttonParsers.specific(language, settings.embed, 'embed', name, undefined),
buttonParsers.specific(language, settings.lvlupdeltimeout, 'lvlupdeltimeout', name, undefined),
buttonParsers.specific(language, settings.pingUser, 'pingUser', name, undefined),
buttonParsers.specific(
language,
settings.lvlupchannels,
Expand Down
16 changes: 12 additions & 4 deletions src/Events/BotEvents/messageEvents/messageCreate/levelling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,14 @@ const doEmbed = async (
}

if (!embed) return;
send(msg, embed, setting);
send(msg, embed, setting, user);
};

const send = async (
msg: Discord.Message<true> | Discord.BaseGuildVoiceChannel,
const send = async <T extends Discord.Message<true> | Discord.BaseGuildVoiceChannel>(
msg: T,
embed: Discord.APIEmbed,
setting: Prisma.leveling,
user: T extends Discord.Message<true> ? undefined : Discord.User,
) => {
const channelId = msg instanceof Discord.Message ? msg.channelId : msg.id;

Expand All @@ -619,7 +620,14 @@ const send = async (
id: setting.lvlupchannels.length ? setting.lvlupchannels : [channelId],
guildId: msg.guildId,
},
{ embeds: [embed] },
{
embeds: [embed],
content:
setting.pingUser && setting.lvlupchannels.length
? `<@${(msg instanceof Discord.Message ? msg.author : user)!.id}>`
: undefined,
allowed_mentions: { replied_user: setting.pingUser },
},
)
.then((m) => m?.filter((ms): ms is Discord.Message<true> => !!ms));

Expand Down
4 changes: 4 additions & 0 deletions src/Languages/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -3348,6 +3348,10 @@
"text": "Text specific"
},
"fields": {
"pingUser": {
"name": "Ping User",
"desc": "Whether to Ping the User when they Level-Up"
},
"textenabled": {
"name": "Text-XP Enabled",
"desc": "Whether to award XP for Text Messages"
Expand Down

0 comments on commit 666d4a3

Please sign in to comment.