Skip to content

Commit

Permalink
refactor: remove capitalise-string util
Browse files Browse the repository at this point in the history
  • Loading branch information
jejebecarte committed Dec 2, 2024
1 parent 24bb7b9 commit df0beab
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 48 deletions.
3 changes: 1 addition & 2 deletions src/commands/promote-demote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js';
import capitaliseString from '@util/capitalise-string';

export default {
data: {
Expand Down Expand Up @@ -39,7 +38,7 @@ export default {
await bot.executeTask(`/g ${type} ${user}`);
embed
.setColor(type === 'promote' ? 'Green' : 'Red')
.setTitle(capitaliseString(`${type}d!`))
.setTitle(type === 'promote' ? 'Promoted!' : 'Demoted!')
.setDescription(`${user} has been ${type}d!`);
} catch (e) {
embed
Expand Down
3 changes: 1 addition & 2 deletions src/commands/toggle-mute.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js';
import capitaliseString from '@util/capitalise-string';

export default {
data: {
Expand Down Expand Up @@ -49,7 +48,7 @@ export default {
try {
await bot.executeTask(`/g ${type} ${user} ${duration}`);
embed
.setTitle(capitaliseString(`${type}d!`))
.setTitle(type === 'mute' ? 'Muted!' : 'Unmuted!')
.setDescription(
`${user} was ${type}d${type === 'mute' ? ` for ${duration}!` : '!'}`
)
Expand Down
8 changes: 4 additions & 4 deletions src/events/mineflayer/chat/member-kick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export default {
bot,
rank: string | undefined,
playerName: string,
kickedByRank: string | undefined,
kickedByPlayerName: string
kickerRank: string | undefined,
kickerName: string
) => {
await bot.sendToDiscord(
'gc',
`${Emojis.negativeGuildEvent} **${rank ? `${rank} ` : ''}${escapeMarkdown(
playerName
)}** was kicked by **${kickedByRank ? `${kickedByRank} ` : ''}${escapeMarkdown(
kickedByPlayerName
)}** was kicked by **${kickerRank ? `${kickerRank} ` : ''}${escapeMarkdown(
kickerName
)}**`,
undefined,
true
Expand Down
6 changes: 3 additions & 3 deletions src/events/mineflayer/chat/promote-demote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export default {
rank: string | undefined,
playerName: string,
type: 'promoted' | 'demoted',
guildRankFrom: string,
guildRankTo: string
originalRank: string,
newRank: string
) => {
await bot.sendToDiscord(
'gc',
`${type === 'promoted' ? Emojis.positiveGuildEvent : Emojis.negativeGuildEvent} **${
rank ? `${rank} ` : ''
}${escapeMarkdown(playerName)}** was ${type} to ${guildRankTo} from ${guildRankFrom}!`,
}${escapeMarkdown(playerName)}** was ${type} to ${newRank} from ${originalRank}!`,
getRankColor(rank),
true
);
Expand Down
10 changes: 5 additions & 5 deletions src/events/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
* Returns:
* - Hypixel Rank
* - Player Name
* - muted / unmuted
* - Type (muted / unmuted)
* - Muter Hypixel Rank
* - Muter Player Name
* - Muter Player Name
Expand All @@ -49,7 +49,7 @@ export default {
*
* Returns:
* - Player Name
* - joined / left
* - Type (joined / left)
*/
'chat:joinLeave': /^Guild > (\w{2,17}).*? (joined|left)\.$/,

Expand All @@ -76,7 +76,7 @@ export default {
* When "/g online" is typed, and the online and total member count is shown
*
* Returns:
* - Online / Total
* - Type (Online / Total)
* - Member Count
*/
'chat:memberCount': /^(Online|Total) Members: (\d+)$/,
Expand All @@ -87,7 +87,7 @@ export default {
* Returns:
* - Hypixel Rank
* - Player Name
* - joined / left
* - Type (joined / left)
*/
'chat:memberJoinLeave': /^(\[.*])?\s*(\w{2,17}).*? (joined|left) the guild!$/,

Expand All @@ -109,7 +109,7 @@ export default {
* Returns:
* - Hypixel Rank
* - Player Name
* - promoted / demoted
* - Type (promoted / demoted)
* - From Rank
* - To Rank
*/
Expand Down
1 change: 0 additions & 1 deletion src/util/capitalise-string.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/util/emojis.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
export default {
/**
* Join Emoji
*/
join: '📥',

/**
* Leave Emoji
*/
leave: '📤',

/**
* Success Emoji
*/
success: '✅',

/**
* Error Emoji
*/
error: '❌',

/**
* Warning Emoji
*/
warning: '⚠️',

/**
* Alert Emoji
*/
alert: '🚨',

/**
* Positive Guild Event Emoji
*/
positiveGuildEvent: '🎉',

/**
* Negative Guild Event Emoji
*/
negativeGuildEvent: '👋',
};
3 changes: 3 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (' '.tri) {
console.log('true');

Check warning on line 2 in test.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
}

0 comments on commit df0beab

Please sign in to comment.