3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 14:11:50 +00:00

Run prettier and check tslint on entire codebase

Mainly to run these checks for the recent pull requests.
This commit is contained in:
Dragory 2020-01-12 11:47:54 +02:00
parent 65880d2e60
commit 1aceb55a87
15 changed files with 89 additions and 60 deletions

View file

@ -50,6 +50,9 @@ export class GuildLogs extends EventEmitter {
} }
clearIgnoredLog(type: LogType, ignoreId: any) { clearIgnoredLog(type: LogType, ignoreId: any) {
this.ignoredLogs.splice(this.ignoredLogs.findIndex(info => type === info.type && ignoreId === info.ignoreId), 1); this.ignoredLogs.splice(
this.ignoredLogs.findIndex(info => type === info.type && ignoreId === info.ignoreId),
1,
);
} }
} }

View file

@ -41,7 +41,7 @@ export class GuildReminders extends BaseGuildRepository {
channel_id: channelId, channel_id: channelId,
remind_at: remindAt, remind_at: remindAt,
body, body,
created_at created_at,
}); });
} }
} }

View file

@ -19,7 +19,10 @@ export class ApiLogin {
@Column() @Column()
expires_at: string; expires_at: string;
@ManyToOne(type => ApiUserInfo, userInfo => userInfo.logins) @ManyToOne(
type => ApiUserInfo,
userInfo => userInfo.logins,
)
@JoinColumn({ name: "user_id" }) @JoinColumn({ name: "user_id" })
userInfo: ApiUserInfo; userInfo: ApiUserInfo;
} }

View file

@ -18,7 +18,10 @@ export class ApiPermissionAssignment {
@Column("simple-array") @Column("simple-array")
permissions: string[]; permissions: string[];
@ManyToOne(type => ApiUserInfo, userInfo => userInfo.permissionAssignments) @ManyToOne(
type => ApiUserInfo,
userInfo => userInfo.permissionAssignments,
)
@JoinColumn({ name: "target_id" }) @JoinColumn({ name: "target_id" })
userInfo: ApiUserInfo; userInfo: ApiUserInfo;
} }

View file

@ -20,9 +20,15 @@ export class ApiUserInfo {
@Column() @Column()
updated_at: string; updated_at: string;
@OneToMany(type => ApiLogin, login => login.userInfo) @OneToMany(
type => ApiLogin,
login => login.userInfo,
)
logins: ApiLogin[]; logins: ApiLogin[];
@OneToMany(type => ApiPermissionAssignment, p => p.userInfo) @OneToMany(
type => ApiPermissionAssignment,
p => p.userInfo,
)
permissionAssignments: ApiPermissionAssignment[]; permissionAssignments: ApiPermissionAssignment[];
} }

View file

@ -29,6 +29,9 @@ export class Case {
@Column() pp_name: string; @Column() pp_name: string;
@OneToMany(type => CaseNote, note => note.case) @OneToMany(
type => CaseNote,
note => note.case,
)
notes: CaseNote[]; notes: CaseNote[];
} }

View file

@ -15,7 +15,10 @@ export class CaseNote {
@Column() created_at: string; @Column() created_at: string;
@ManyToOne(type => Case, theCase => theCase.notes) @ManyToOne(
type => Case,
theCase => theCase.notes,
)
@JoinColumn({ name: "case_id" }) @JoinColumn({ name: "case_id" })
case: Case; case: Case;
} }

View file

@ -16,5 +16,5 @@ export class Reminder {
@Column() body: string; @Column() body: string;
@Column() created_at: string @Column() created_at: string;
} }

View file

@ -1,18 +1,18 @@
import {MigrationInterface, QueryRunner, TableColumn} from "typeorm"; import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
export class CreateReminderCreatedAtField1578445483917 implements MigrationInterface { export class CreateReminderCreatedAtField1578445483917 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.addColumn(
"reminders",
new TableColumn({
name: "created_at",
type: "datetime",
isNullable: false,
}),
);
}
public async up(queryRunner: QueryRunner): Promise<any> { public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.addColumn("reminders", await queryRunner.dropColumn("reminders", "created_at");
new TableColumn({ }
name: "created_at",
type: "datetime",
isNullable: false
}));
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropColumn("reminders", "created_at");
}
} }

View file

@ -125,7 +125,10 @@ export class MessageSaverPlugin extends ZeppelinPlugin<TConfigSchema> {
await msg.channel.createMessage(`Saving pins from <#${args.channel.id}>...`); await msg.channel.createMessage(`Saving pins from <#${args.channel.id}>...`);
const pins = await args.channel.getPins(); const pins = await args.channel.getPins();
const { savedCount, failed } = await this.saveMessagesToDB(args.channel, pins.map(m => m.id)); const { savedCount, failed } = await this.saveMessagesToDB(
args.channel,
pins.map(m => m.id),
);
if (failed.length) { if (failed.length) {
msg.channel.createMessage( msg.channel.createMessage(

View file

@ -197,7 +197,10 @@ export class ModActionsPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
clearIgnoredEvent(type: IgnoredEventType, userId: any) { clearIgnoredEvent(type: IgnoredEventType, userId: any) {
this.ignoredEvents.splice(this.ignoredEvents.findIndex(info => type === info.type && userId === info.userId), 1); this.ignoredEvents.splice(
this.ignoredEvents.findIndex(info => type === info.type && userId === info.userId),
1,
);
} }
formatReasonWithAttachments(reason: string, attachments: Attachment[]) { formatReasonWithAttachments(reason: string, attachments: Attachment[]) {

View file

@ -70,19 +70,18 @@ export class RemindersPlugin extends ZeppelinPlugin<TConfigSchema> {
const channel = this.guild.channels.get(reminder.channel_id); const channel = this.guild.channels.get(reminder.channel_id);
if (channel && channel instanceof TextChannel) { if (channel && channel instanceof TextChannel) {
try { try {
//Only show created at date if one exists // Only show created at date if one exists
if(moment(reminder.created_at).isValid()){ if (moment(reminder.created_at).isValid()) {
const target = moment(); const target = moment();
const diff = target.diff(moment(reminder.created_at , "YYYY-MM-DD HH:mm:ss")); const diff = target.diff(moment(reminder.created_at, "YYYY-MM-DD HH:mm:ss"));
const result = humanizeDuration(diff, { largest: 2, round: true }); const result = humanizeDuration(diff, { largest: 2, round: true });
await channel.createMessage( await channel.createMessage(
disableLinkPreviews(`Reminder for <@!${reminder.user_id}>: ${reminder.body} \n\`Set at ${reminder.created_at} (${result} ago)\``), disableLinkPreviews(
); `Reminder for <@!${reminder.user_id}>: ${reminder.body} \n\`Set at ${reminder.created_at} (${result} ago)\``,
} ),
else{
await channel.createMessage(
disableLinkPreviews(`Reminder for <@!${reminder.user_id}>: ${reminder.body}`),
); );
} else {
await channel.createMessage(disableLinkPreviews(`Reminder for <@!${reminder.user_id}>: ${reminder.body}`));
} }
} catch (e) { } catch (e) {
// Probably random Discord internal server error or missing permissions or somesuch // Probably random Discord internal server error or missing permissions or somesuch
@ -138,7 +137,13 @@ export class RemindersPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
const reminderBody = args.reminder || `https://discordapp.com/channels/${this.guildId}/${msg.channel.id}/${msg.id}`; const reminderBody = args.reminder || `https://discordapp.com/channels/${this.guildId}/${msg.channel.id}/${msg.id}`;
await this.reminders.add(msg.author.id, msg.channel.id, reminderTime.format("YYYY-MM-DD HH:mm:ss"), reminderBody, moment().format("YYYY-MM-DD HH:mm:ss")); await this.reminders.add(
msg.author.id,
msg.channel.id,
reminderTime.format("YYYY-MM-DD HH:mm:ss"),
reminderBody,
moment().format("YYYY-MM-DD HH:mm:ss"),
);
const msUntilReminder = reminderTime.diff(now); const msUntilReminder = reminderTime.diff(now);
const timeUntilReminder = humanizeDuration(msUntilReminder, { largest: 2, round: true }); const timeUntilReminder = humanizeDuration(msUntilReminder, { largest: 2, round: true });
@ -163,7 +168,7 @@ export class RemindersPlugin extends ZeppelinPlugin<TConfigSchema> {
const lines = Array.from(reminders.entries()).map(([i, reminder]) => { const lines = Array.from(reminders.entries()).map(([i, reminder]) => {
const num = i + 1; const num = i + 1;
const paddedNum = num.toString().padStart(longestNum, " "); const paddedNum = num.toString().padStart(longestNum, " ");
const target = moment(reminder.remind_at , "YYYY-MM-DD HH:mm:ss"); const target = moment(reminder.remind_at, "YYYY-MM-DD HH:mm:ss");
const diff = target.diff(moment()); const diff = target.diff(moment());
const result = humanizeDuration(diff, { largest: 2, round: true }); const result = humanizeDuration(diff, { largest: 2, round: true });
return `\`${paddedNum}.\` \`${reminder.remind_at} (${result})\` ${reminder.body}`; return `\`${paddedNum}.\` \`${reminder.remind_at} (${result})\` ${reminder.body}`;

View file

@ -797,11 +797,11 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
name: "compact", name: "compact",
shortcut: "c", shortcut: "c",
isSwitch: true, isSwitch: true,
} },
] ],
}) })
@d.permission("can_info") @d.permission("can_info")
async infoCmd(msg: Message, args: { user?: User | UnknownUser, compact?: boolean }) { async infoCmd(msg: Message, args: { user?: User | UnknownUser; compact?: boolean }) {
const user = args.user || msg.author; const user = args.user || msg.author;
let member; let member;
@ -823,22 +823,21 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
embed.title = `${user.username}#${user.discriminator}`; embed.title = `${user.username}#${user.discriminator}`;
embed.thumbnail = { url: user.avatarURL }; embed.thumbnail = { url: user.avatarURL };
if(args.compact){ if (args.compact) {
embed.fields.push({ embed.fields.push({
name: "User information", name: "User information",
value: value: trimLines(`
trimLines(`
Profile: <@!${user.id}> Profile: <@!${user.id}>
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})** Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
`), `),
}); });
if (member) { if (member) {
const joinedAt = moment(member.joinedAt); const joinedAt = moment(member.joinedAt);
const joinAge = humanizeDuration(moment().valueOf() - member.joinedAt, { const joinAge = humanizeDuration(moment().valueOf() - member.joinedAt, {
largest: 2, largest: 2,
round: true, round: true,
}); });
embed.fields[0].value += `\nJoined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**` embed.fields[0].value += `\nJoined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**`;
} else { } else {
embed.fields.push({ embed.fields.push({
name: "!! USER IS NOT ON THE SERVER !!", name: "!! USER IS NOT ON THE SERVER !!",
@ -847,8 +846,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
msg.channel.createMessage({ embed }); msg.channel.createMessage({ embed });
return; return;
} } else {
else{
embed.fields.push({ embed.fields.push({
name: "User information", name: "User information",
value: value:
@ -857,7 +855,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
Profile: <@!${user.id}> Profile: <@!${user.id}>
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})** Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
`) + embedPadding, `) + embedPadding,
}); });
} }
} else { } else {
embed.title = `Unknown user`; embed.title = `Unknown user`;
@ -897,7 +895,6 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
name: "!! USER IS NOT ON THE SERVER !!", name: "!! USER IS NOT ON THE SERVER !!",
value: embedPadding, value: embedPadding,
}); });
} }
const cases = (await this.cases.getByUserId(user.id)).filter(c => !c.is_hidden); const cases = (await this.cases.getByUserId(user.id)).filter(c => !c.is_hidden);
@ -920,7 +917,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
`), `),
}); });
} }
msg.channel.createMessage({ embed }); msg.channel.createMessage({ embed });
} }

View file

@ -27,7 +27,7 @@ import { LocatePlugin } from "./LocateUser";
import { GuildConfigReloader } from "./GuildConfigReloader"; import { GuildConfigReloader } from "./GuildConfigReloader";
import { ChannelArchiverPlugin } from "./ChannelArchiver"; import { ChannelArchiverPlugin } from "./ChannelArchiver";
import { AutomodPlugin } from "./Automod"; import { AutomodPlugin } from "./Automod";
import { RolesPlugin} from "./Roles"; import { RolesPlugin } from "./Roles";
/** /**
* Plugins available to be loaded for individual guilds * Plugins available to be loaded for individual guilds

View file

@ -956,25 +956,25 @@ export async function resolveMember(bot: Client, guild: Guild, value: string): P
return null; return null;
} }
export async function resolveRoleId(bot: Client, guildId: string, value: string){ export async function resolveRoleId(bot: Client, guildId: string, value: string) {
if(value == null){ if (value == null) {
return null; return null;
} }
//role mention // Role mention
const mentionMatch = value.match(/^<@&?(\d+)>$/); const mentionMatch = value.match(/^<@&?(\d+)>$/);
if(mentionMatch){ if (mentionMatch) {
return mentionMatch[1]; return mentionMatch[1];
} }
//role name // Role name
let roleList = await bot.getRESTGuildRoles(guildId); const roleList = await bot.getRESTGuildRoles(guildId);
let role = roleList.filter(x => x.name.toLocaleLowerCase() == value.toLocaleLowerCase()); const role = roleList.filter(x => x.name.toLocaleLowerCase() === value.toLocaleLowerCase());
if(role[0]){ if (role[0]) {
return role[0].id; return role[0].id;
} }
//role ID // Role ID
const idMatch = value.match(/^\d+$/); const idMatch = value.match(/^\d+$/);
if (idMatch) { if (idMatch) {
return value; return value;