Reformat all files with Prettier

This commit is contained in:
Dragory 2021-09-11 19:06:51 +03:00
parent 0cde0d46d2
commit ac79eb09f5
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
206 changed files with 727 additions and 888 deletions

View file

@ -42,7 +42,7 @@ const defaultOptions: PluginOptions<ReactionRolesPluginType> = {
const MAXIMUM_COMPONENT_ROWS = 5;
const configPreprocessor: ConfigPreprocessorFn<ReactionRolesPluginType> = options => {
const configPreprocessor: ConfigPreprocessorFn<ReactionRolesPluginType> = (options) => {
if (options.config.button_groups) {
for (const [groupName, group] of Object.entries(options.config.button_groups)) {
const defaultButtonNames = Object.keys(group.default_buttons);

View file

@ -58,17 +58,15 @@ export const InitReactionRolesCmd = reactionRolesCmd({
const emojiRolePairs: TReactionRolePair[] = args.reactionRolePairs
.trim()
.split("\n")
.map(v => v.split(/[\s=,]+/).map(v => v.trim())) // tslint:disable-line
.map(
(pair): TReactionRolePair => {
const customEmojiMatch = pair[0].match(/^<a?:(.*?):(\d+)>$/);
if (customEmojiMatch) {
return [customEmojiMatch[2], pair[1], customEmojiMatch[1]];
} else {
return pair as TReactionRolePair;
}
},
);
.map((v) => v.split(/[\s=,]+/).map((v) => v.trim())) // tslint:disable-line
.map((pair): TReactionRolePair => {
const customEmojiMatch = pair[0].match(/^<a?:(.*?):(\d+)>$/);
if (customEmojiMatch) {
return [customEmojiMatch[2], pair[1], customEmojiMatch[1]];
} else {
return pair as TReactionRolePair;
}
});
// Verify the specified emojis and roles are valid and usable
for (const pair of emojiRolePairs) {

View file

@ -31,9 +31,7 @@ export const PostButtonRolesCmd = reactionRolesCmd({
const buttons: MessageButton[] = [];
const toInsert: Array<{ customId; buttonGroup; buttonName }> = [];
for (const [buttonName, button] of Object.entries(group.default_buttons)) {
const customId = createHash("md5")
.update(`${buttonName}${moment.utc().valueOf()}`)
.digest("hex");
const customId = createHash("md5").update(`${buttonName}${moment.utc().valueOf()}`).digest("hex");
const btn = new MessageButton()
.setLabel(button.label ?? "")

View file

@ -29,7 +29,7 @@ export const AddReactionRoleEvt = reactionRolesEvt({
if (emoji.name === CLEAR_ROLES_EMOJI) {
// User reacted with "clear roles" emoji -> clear their roles
const reactionRoleRoleIds = reactionRoles.map(rr => rr.role_id);
const reactionRoleRoleIds = reactionRoles.map((rr) => rr.role_id);
for (const roleId of reactionRoleRoleIds) {
addMemberPendingRoleChange(pluginData, userId, "-", roleId);
}

View file

@ -65,7 +65,7 @@ export async function applyReactionRoleReactionsToMessage(
await sleep(1500);
// Add reaction role reactions
const emojisToAdd = reactionRoles.map(rr => rr.emoji);
const emojisToAdd = reactionRoles.map((rr) => rr.emoji);
emojisToAdd.push(CLEAR_ROLES_EMOJI);
for (const rawEmoji of emojisToAdd) {

View file

@ -5,7 +5,7 @@ import { refreshReactionRoles } from "./refreshReactionRoles";
export async function runAutoRefresh(pluginData: GuildPluginData<ReactionRolesPluginType>) {
// Refresh reaction roles on all reaction role messages
const reactionRoles = await pluginData.state.reactionRoles.all();
const idPairs = new Set(reactionRoles.map(r => `${r.channel_id}-${r.message_id}`));
const idPairs = new Set(reactionRoles.map((r) => `${r.channel_id}-${r.message_id}`));
for (const pair of idPairs) {
const [channelId, messageId] = pair.split("-");
await refreshReactionRoles(pluginData, channelId, messageId);