mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Change prettier line width from 80 to 100, reformat files
This commit is contained in:
parent
7e688ac899
commit
69224810cd
4 changed files with 36 additions and 99 deletions
3
.prettierrc
Normal file
3
.prettierrc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"printWidth": 100
|
||||||
|
}
|
|
@ -28,16 +28,14 @@ export class LogsPlugin extends Plugin {
|
||||||
"⚠️ **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was warned by {mod.user.username}#{mod.user.discriminator}",
|
"⚠️ **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was warned by {mod.user.username}#{mod.user.discriminator}",
|
||||||
MEMBER_MUTE:
|
MEMBER_MUTE:
|
||||||
"🔇 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was muted by {mod.user.username}#{mod.user.discriminator}",
|
"🔇 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was muted by {mod.user.username}#{mod.user.discriminator}",
|
||||||
MEMBER_UNMUTE:
|
MEMBER_UNMUTE: "🔉 **{member.user.username}#{member.user.discriminator}** was unmuted",
|
||||||
"🔉 **{member.user.username}#{member.user.discriminator}** was unmuted",
|
|
||||||
MEMBER_KICK:
|
MEMBER_KICK:
|
||||||
"👢 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was kicked by {mod.user.username}#{mod.user.discriminator}",
|
"👢 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was kicked by {mod.user.username}#{mod.user.discriminator}",
|
||||||
MEMBER_BAN:
|
MEMBER_BAN:
|
||||||
"🔨 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was banned by {mod.user.username}#{mod.user.discriminator}",
|
"🔨 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was banned by {mod.user.username}#{mod.user.discriminator}",
|
||||||
MEMBER_JOIN:
|
MEMBER_JOIN:
|
||||||
"📥 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) joined{new} (created {account_age})",
|
"📥 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) joined{new} (created {account_age})",
|
||||||
MEMBER_LEAVE:
|
MEMBER_LEAVE: "📤 **{member.user.username}#{member.user.discriminator}** left the server",
|
||||||
"📤 **{member.user.username}#{member.user.discriminator}** left the server",
|
|
||||||
MEMBER_ROLE_ADD:
|
MEMBER_ROLE_ADD:
|
||||||
"🔑 **{member.user.username}#{member.user.discriminator}** role added **{role.name}** by {mod.user.username}#{mod.user.discriminator}",
|
"🔑 **{member.user.username}#{member.user.discriminator}** role added **{role.name}** by {mod.user.username}#{mod.user.discriminator}",
|
||||||
MEMBER_ROLE_REMOVE:
|
MEMBER_ROLE_REMOVE:
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
import { Plugin, decorators as d, waitForReaction } from "knub";
|
import { Plugin, decorators as d, waitForReaction } from "knub";
|
||||||
import {
|
import { Guild, GuildAuditLogEntry, Member, Message, TextChannel, User } from "eris";
|
||||||
Guild,
|
|
||||||
GuildAuditLogEntry,
|
|
||||||
Member,
|
|
||||||
Message,
|
|
||||||
TextChannel,
|
|
||||||
User
|
|
||||||
} from "eris";
|
|
||||||
import * as moment from "moment-timezone";
|
import * as moment from "moment-timezone";
|
||||||
import * as humanizeDuration from "humanize-duration";
|
import * as humanizeDuration from "humanize-duration";
|
||||||
import { GuildModActions } from "../data/GuildModActions";
|
import { GuildModActions } from "../data/GuildModActions";
|
||||||
|
@ -44,10 +37,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
|
|
||||||
// Check for expired mutes every 5s
|
// Check for expired mutes every 5s
|
||||||
this.clearExpiredMutes();
|
this.clearExpiredMutes();
|
||||||
this.muteClearIntervalId = setInterval(
|
this.muteClearIntervalId = setInterval(() => this.clearExpiredMutes(), 5000);
|
||||||
() => this.clearExpiredMutes(),
|
|
||||||
5000
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUnload() {
|
async onUnload() {
|
||||||
|
@ -68,14 +58,10 @@ export class ModActionsPlugin extends Plugin {
|
||||||
message_on_ban: false,
|
message_on_ban: false,
|
||||||
message_channel: null,
|
message_channel: null,
|
||||||
warn_message: "You have received a warning on {guildName}: {reason}",
|
warn_message: "You have received a warning on {guildName}: {reason}",
|
||||||
mute_message:
|
mute_message: "You have been muted on {guildName}. Reason given: {reason}",
|
||||||
"You have been muted on {guildName}. Reason given: {reason}",
|
timed_mute_message: "You have been muted on {guildName} for {time}. Reason given: {reason}",
|
||||||
timed_mute_message:
|
kick_message: "You have been kicked from {guildName}. Reason given: {reason}",
|
||||||
"You have been muted on {guildName} for {time}. Reason given: {reason}",
|
ban_message: "You have been banned from {guildName}. Reason given: {reason}",
|
||||||
kick_message:
|
|
||||||
"You have been kicked from {guildName}. Reason given: {reason}",
|
|
||||||
ban_message:
|
|
||||||
"You have been banned from {guildName}. Reason given: {reason}",
|
|
||||||
log_automatic_actions: true,
|
log_automatic_actions: true,
|
||||||
action_log_channel: null,
|
action_log_channel: null,
|
||||||
alert_on_rejoin: false,
|
alert_on_rejoin: false,
|
||||||
|
@ -112,10 +98,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
@d.event("guildBanAdd")
|
@d.event("guildBanAdd")
|
||||||
async onGuildBanAdd(guild: Guild, user: User) {
|
async onGuildBanAdd(guild: Guild, user: User) {
|
||||||
await sleep(1000); // Wait a moment for the audit log to update
|
await sleep(1000); // Wait a moment for the audit log to update
|
||||||
const relevantAuditLogEntry = await this.findRelevantAuditLogEntry(
|
const relevantAuditLogEntry = await this.findRelevantAuditLogEntry("MEMBER_BAN_ADD", user.id);
|
||||||
"MEMBER_BAN_ADD",
|
|
||||||
user.id
|
|
||||||
);
|
|
||||||
|
|
||||||
if (relevantAuditLogEntry) {
|
if (relevantAuditLogEntry) {
|
||||||
const modId = relevantAuditLogEntry.user.id;
|
const modId = relevantAuditLogEntry.user.id;
|
||||||
|
@ -149,14 +132,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
const modId = relevantAuditLogEntry.user.id;
|
const modId = relevantAuditLogEntry.user.id;
|
||||||
const auditLogId = relevantAuditLogEntry.id;
|
const auditLogId = relevantAuditLogEntry.id;
|
||||||
|
|
||||||
await this.createModAction(
|
await this.createModAction(user.id, modId, ModActionType.Unban, auditLogId, null, true);
|
||||||
user.id,
|
|
||||||
modId,
|
|
||||||
ModActionType.Unban,
|
|
||||||
auditLogId,
|
|
||||||
null,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
await this.createModAction(user.id, null, ModActionType.Unban);
|
await this.createModAction(user.id, null, ModActionType.Unban);
|
||||||
}
|
}
|
||||||
|
@ -177,9 +153,9 @@ export class ModActionsPlugin extends Plugin {
|
||||||
if (actions.length) {
|
if (actions.length) {
|
||||||
const alertChannel: any = this.guild.channels.get(alertChannelId);
|
const alertChannel: any = this.guild.channels.get(alertChannelId);
|
||||||
alertChannel.send(
|
alertChannel.send(
|
||||||
`<@!${member.id}> (${member.user.username}#${
|
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${
|
||||||
member.user.discriminator
|
member.id
|
||||||
} \`${member.id}\`) joined with ${actions.length} prior record(s)`
|
}\`) joined with ${actions.length} prior record(s)`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,13 +187,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
@d.command("note", "<userId:string> <note:string$>")
|
@d.command("note", "<userId:string> <note:string$>")
|
||||||
@d.permission("note")
|
@d.permission("note")
|
||||||
async noteCmd(msg: Message, args: any) {
|
async noteCmd(msg: Message, args: any) {
|
||||||
await this.createModAction(
|
await this.createModAction(args.userId, msg.author.id, ModActionType.Note, null, args.note);
|
||||||
args.userId,
|
|
||||||
msg.author.id,
|
|
||||||
ModActionType.Note,
|
|
||||||
null,
|
|
||||||
args.note
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@d.command("warn", "<member:Member> <reason:string$>")
|
@d.command("warn", "<member:Member> <reason:string$>")
|
||||||
|
@ -265,9 +235,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
@d.permission("mute")
|
@d.permission("mute")
|
||||||
async muteCmd(msg: Message, args: any) {
|
async muteCmd(msg: Message, args: any) {
|
||||||
if (!this.configValue("mute_role")) {
|
if (!this.configValue("mute_role")) {
|
||||||
msg.channel.createMessage(
|
msg.channel.createMessage(errorMessage("Cannot mute: no mute role specified"));
|
||||||
errorMessage("Cannot mute: no mute role specified")
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,14 +274,11 @@ export class ModActionsPlugin extends Plugin {
|
||||||
? this.configValue("timed_mute_message")
|
? this.configValue("timed_mute_message")
|
||||||
: this.configValue("mute_message");
|
: this.configValue("mute_message");
|
||||||
|
|
||||||
const muteMessage = formatTemplateString(
|
const muteMessage = formatTemplateString(template, {
|
||||||
template,
|
guildName: this.guild.name,
|
||||||
{
|
reason: args.reason,
|
||||||
guildName: this.guild.name,
|
time: timeUntilUnmute
|
||||||
reason: args.reason,
|
});
|
||||||
time: timeUntilUnmute
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
messageSent = await this.tryToMessageUser(
|
messageSent = await this.tryToMessageUser(
|
||||||
args.member.user,
|
args.member.user,
|
||||||
|
@ -350,9 +315,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
async showcaseCmd(msg: Message, args: any) {
|
async showcaseCmd(msg: Message, args: any) {
|
||||||
if (args.caseNumberOrUserId.length >= 17) {
|
if (args.caseNumberOrUserId.length >= 17) {
|
||||||
// Assume user id
|
// Assume user id
|
||||||
const actions = await this.modActions.getByUserId(
|
const actions = await this.modActions.getByUserId(args.caseNumberOrUserId);
|
||||||
args.caseNumberOrUserId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (actions.length === 0) {
|
if (actions.length === 0) {
|
||||||
msg.channel.createMessage("No cases found for the specified user!");
|
msg.channel.createMessage("No cases found for the specified user!");
|
||||||
|
@ -363,9 +326,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Assume case id
|
// Assume case id
|
||||||
const action = await this.modActions.findByCaseNumber(
|
const action = await this.modActions.findByCaseNumber(args.caseNumberOrUserId);
|
||||||
args.caseNumberOrUserId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!action) {
|
if (!action) {
|
||||||
msg.channel.createMessage("Case not found!");
|
msg.channel.createMessage("Case not found!");
|
||||||
|
@ -383,7 +344,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
|
|
||||||
const ourLevel = this.getMemberLevel(member1);
|
const ourLevel = this.getMemberLevel(member1);
|
||||||
const memberLevel = this.getMemberLevel(member2);
|
const memberLevel = this.getMemberLevel(member2);
|
||||||
return (ourLevel > memberLevel);
|
return ourLevel > memberLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -412,9 +373,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
|
|
||||||
if (useChannel && this.configValue("message_channel")) {
|
if (useChannel && this.configValue("message_channel")) {
|
||||||
try {
|
try {
|
||||||
const channel = this.guild.channels.get(
|
const channel = this.guild.channels.get(this.configValue("message_channel")) as TextChannel;
|
||||||
this.configValue("message_channel")
|
|
||||||
) as TextChannel;
|
|
||||||
await channel.createMessage(`<@!${user.id}> ${str}`);
|
await channel.createMessage(`<@!${user.id}> ${str}`);
|
||||||
messageSent = true;
|
messageSent = true;
|
||||||
} catch (e) {} // tslint:disable-line
|
} catch (e) {} // tslint:disable-line
|
||||||
|
@ -427,10 +386,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
* Shows information about the specified action in a message embed.
|
* Shows information about the specified action in a message embed.
|
||||||
* If no channelId is specified, uses the channel id from config.
|
* If no channelId is specified, uses the channel id from config.
|
||||||
*/
|
*/
|
||||||
protected async displayModAction(
|
protected async displayModAction(actionOrId: ModAction | number, channelId: string) {
|
||||||
actionOrId: ModAction | number,
|
|
||||||
channelId: string
|
|
||||||
) {
|
|
||||||
let action: ModAction;
|
let action: ModAction;
|
||||||
if (typeof actionOrId === "number") {
|
if (typeof actionOrId === "number") {
|
||||||
action = await this.modActions.find(actionOrId);
|
action = await this.modActions.find(actionOrId);
|
||||||
|
@ -477,9 +433,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
notes.forEach((note: any) => {
|
notes.forEach((note: any) => {
|
||||||
const noteDate = moment(note.created_at);
|
const noteDate = moment(note.created_at);
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: `${note.mod_name} at ${noteDate.format(
|
name: `${note.mod_name} at ${noteDate.format("YYYY-MM-DD [at] HH:mm")}:`,
|
||||||
"YYYY-MM-DD [at] HH:mm"
|
|
||||||
)}:`,
|
|
||||||
value: note.body
|
value: note.body
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -490,9 +444,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
(this.bot.guilds
|
(this.bot.guilds.get(this.guildId).channels.get(channelId) as TextChannel).createMessage({
|
||||||
.get(this.guildId)
|
|
||||||
.channels.get(channelId) as TextChannel).createMessage({
|
|
||||||
embed
|
embed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -515,11 +467,7 @@ export class ModActionsPlugin extends Plugin {
|
||||||
actionType: string,
|
actionType: string,
|
||||||
userId: string
|
userId: string
|
||||||
): Promise<GuildAuditLogEntry> {
|
): Promise<GuildAuditLogEntry> {
|
||||||
const auditLogEntries = await this.bot.getGuildAuditLogs(
|
const auditLogEntries = await this.bot.getGuildAuditLogs(this.guildId, 5, actionType);
|
||||||
this.guildId,
|
|
||||||
5,
|
|
||||||
actionType
|
|
||||||
);
|
|
||||||
|
|
||||||
auditLogEntries.entries.sort((a, b) => {
|
auditLogEntries.entries.sort((a, b) => {
|
||||||
if (a.createdAt > b.createdAt) return -1;
|
if (a.createdAt > b.createdAt) return -1;
|
||||||
|
@ -545,14 +493,10 @@ export class ModActionsPlugin extends Plugin {
|
||||||
automatic = false
|
automatic = false
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const user = this.bot.users.get(userId);
|
const user = this.bot.users.get(userId);
|
||||||
const userName = user
|
const userName = user ? `${user.username}#${user.discriminator}` : "Unknown#0000";
|
||||||
? `${user.username}#${user.discriminator}`
|
|
||||||
: "Unknown#0000";
|
|
||||||
|
|
||||||
const mod = this.bot.users.get(modId);
|
const mod = this.bot.users.get(modId);
|
||||||
const modName = mod
|
const modName = mod ? `${mod.username}#${mod.discriminator}` : "Unknown#0000";
|
||||||
? `${mod.username}#${mod.discriminator}`
|
|
||||||
: "Unknown#0000";
|
|
||||||
|
|
||||||
const createdId = await this.modActions.create({
|
const createdId = await this.modActions.create({
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
|
@ -579,15 +523,9 @@ export class ModActionsPlugin extends Plugin {
|
||||||
return createdId;
|
return createdId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async createModActionNote(
|
protected async createModActionNote(modActionId: number, modId: string, body: string) {
|
||||||
modActionId: number,
|
|
||||||
modId: string,
|
|
||||||
body: string
|
|
||||||
) {
|
|
||||||
const mod = this.bot.users.get(modId);
|
const mod = this.bot.users.get(modId);
|
||||||
const modName = mod
|
const modName = mod ? `${mod.username}#${mod.discriminator}` : "Unknown#0000";
|
||||||
? `${mod.username}#${mod.discriminator}`
|
|
||||||
: "Unknown#0000";
|
|
||||||
|
|
||||||
return this.modActions.createNote(modActionId, {
|
return this.modActions.createNote(modActionId, {
|
||||||
mod_id: modId,
|
mod_id: modId,
|
||||||
|
|
|
@ -21,9 +21,7 @@ export class UtilityPlugin extends Plugin {
|
||||||
@d.command("roles")
|
@d.command("roles")
|
||||||
@d.permission("roles")
|
@d.permission("roles")
|
||||||
async rolesCmd(msg: Message) {
|
async rolesCmd(msg: Message) {
|
||||||
const roles = (msg.channel as TextChannel).guild.roles.map(
|
const roles = (msg.channel as TextChannel).guild.roles.map(role => `${role.name} ${role.id}`);
|
||||||
role => `${role.name} ${role.id}`
|
|
||||||
);
|
|
||||||
msg.channel.createMessage("```" + roles.join("\n") + "```");
|
msg.channel.createMessage("```" + roles.join("\n") + "```");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue