Skip to content

Commit

Permalink
chore: remove debug code, rename single letter vars
Browse files Browse the repository at this point in the history
  • Loading branch information
laquasicinque committed Sep 1, 2024
1 parent f48081d commit 3b4d038
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
4 changes: 0 additions & 4 deletions src/v2/autorespond/code_parsing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const jsCodeBlocks = createCodeBlockCapturer([
'typescript',
]);

const tap = <T>(x: T): T => {
console.log(x)
return x
}
const getFirstVar = pipe([jsCodeBlocks, pluck('code'), some(hasVarInSource)]);

const messageFor = (userId: string) => `
Expand Down
2 changes: 1 addition & 1 deletion src/v2/commands/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const createNPMEmbed = (
.setURL(url)
.setFooter(
{
text: `requested by ${user.username}#${user.discriminator}`,
text: `requested by ${user.username}`,
iconURL: user.avatarURL({ size: 64, format: 'webp' })
}
)
Expand Down
1 change: 0 additions & 1 deletion src/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ client.on('messageCreate', msg => {
}

if (NON_COMMAND_MSG_TYPES.has(msg.channel.type) && msg.guild) {
console.log("Handled")
handleNonCommandGuildMessages(msg);
}
});
Expand Down
5 changes: 4 additions & 1 deletion src/v2/modules/mod/commands/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const generateButtons = (roles: typeof ROLES | typeof NOTIFY_ROLES) =>
const chunkAndRowify = pipe<
Iterable<ButtonBuilder>,
Iterable<ActionRowBuilder<MessageActionRowComponentBuilder>>
>([chunk(5), map((x: ButtonBuilder[]) => new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(...x))]);
>([
chunk(5),
map((buttonBuilders: ButtonBuilder[]) => new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(...buttonBuilders))
]);

export async function setupRoles(
interaction: CommandInteraction
Expand Down
10 changes: 5 additions & 5 deletions src/v2/modules/onboarding/events/handleNotifyRolesSelected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ export const handleNotifyRolesSelected = async (
const msg = interaction.message as Message;

msg.edit({
components: msg.components.map(x => {
if (x.type === ComponentType.ActionRow) {
return new ActionRowBuilder<MessageActionRowComponentBuilder>(x)
.setComponents(...x.components.map(x => {
components: msg.components.map(component => {
if (component.type === ComponentType.ActionRow) {
return new ActionRowBuilder<MessageActionRowComponentBuilder>(component)
.setComponents(...component.components.map(x => {
if (x.type === ComponentType.Button) {
return new ButtonBuilder(x).setDisabled(true)
}
return x as unknown as MessageActionRowComponentBuilder
}))
}

return x
return component
}),
});

Expand Down
22 changes: 13 additions & 9 deletions src/v2/modules/onboarding/events/handleRoleSelected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ export const handleRoleSelected = async (
});

await msg.edit({
components: msg.components.map(x => {
if (x.type === ComponentType.ActionRow) {
return new ActionRowBuilder<MessageActionRowComponentBuilder>(x).setComponents(x.components.map(x => {
if (x.type === ComponentType.StringSelect) {
return new StringSelectMenuBuilder(x).setDisabled(true)
}
return x as unknown as MessageActionRowComponentBuilder
}))
components: msg.components.map(component => {
if (component.type === ComponentType.ActionRow) {
return new ActionRowBuilder<MessageActionRowComponentBuilder>(component)
.setComponents(
component.components.map(subComponent => {
if (subComponent.type === ComponentType.StringSelect) {
return new StringSelectMenuBuilder(subComponent).setDisabled(true)
}
// This feels wrong, there really should be a better way to edit a component...surely
return subComponent as unknown as MessageActionRowComponentBuilder
})
)
}
return x;
return component;
}),
});

Expand Down
2 changes: 1 addition & 1 deletion src/v2/modules/onboarding/utils/sneakPin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Message, MessageType } from 'discord.js';

export const sneakPin = async (msg: Message): Promise<void> => {
const awaitedPinned = msg.channel.awaitMessages({
filter: x => x.type === MessageType.ChannelPinnedMessage,
filter: msg => msg.type === MessageType.ChannelPinnedMessage,
max: 1,
});

Expand Down
1 change: 0 additions & 1 deletion src/v2/utils/codeBlockCapturer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function createCodeBlockCapturer(
String.raw`${BACKTICKS}(?<language>${langAlts})\n(?<code>[\s\S]+?)\n${BACKTICKS}`,
'gui'
);
console.log({ str })
const matches = str.matchAll(langRegex);
for (const {
groups: { language, code },
Expand Down

0 comments on commit 3b4d038

Please sign in to comment.