lint: automated fix from ESLint

This commit is contained in:
liushuyu 2021-10-28 15:38:02 -06:00
parent 39c8f5979c
commit e2fb430042
No known key found for this signature in database
GPG Key ID: 23D1CE4534419437
10 changed files with 51 additions and 54 deletions

View File

@ -6,4 +6,4 @@ export function command (message: discord.Message) {
message.mentions.users.map(async (user) => {
await ban(user, message.author, message.guild);
});
};
}

View File

@ -18,4 +18,4 @@ export function command (message: discord.Message) {
logger.info(`${message.author.username} has cleared all warnings for ${user} ${user.username} [${count?.length}].`);
await state.logChannel?.send(`${message.author.toString()} has cleared all warnings for ${user.toString()} [${count?.length}].`);
});
};
}

View File

@ -29,7 +29,7 @@ async function updateDatabase () {
}
try {
let response = await fetch(targetServer);
const response = await fetch(targetServer);
body = await response.json();
} catch (e) {
logger.error('Unable to download latest games list!');

View File

@ -33,6 +33,5 @@ export function command (message: discord.Message) {
}).catch(async () => {
await message.channel.send(`User ${user.toString()} was not found in the channel.`);
});
});
}

View File

@ -24,4 +24,4 @@ export async function command (message: discord.Message) {
await message.channel.send(`\`${user.username} (${totalWarnings}) information:\`${warns.length !== 0 ? warnsString : '\n<No warnings>\n'}${bans.length !== 0 ? bansString : '<Not banned>'}`);
});
};
}

View File

@ -2,7 +2,7 @@ import fetch from 'node-fetch';
import discord = require('discord.js');
const fetchOptions = {
headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)', 'Accept': 'application/vnd.github.antiope-preview+json' }
headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)', Accept: 'application/vnd.github.antiope-preview+json' }
};
const repo = process.env.GITHUB_REPOSITORY || 'citra-emu/citra';
@ -16,7 +16,7 @@ export function command(message: discord.Message) {
// use the new GitHub checks API
fetch(`https://api.github.com/repos/${repo}/commits/${headSHA}/check-runs`, fetchOptions).then(response => response.json()).then(async (statuses: any) => {
if (!statuses.check_runs || statuses.total_count < 1) throw new Error('No check runs');
let msg = new discord.MessageEmbed().setTitle(`Status for PR #${pr_number}`).setURL(pr.html_url);
const msg = new discord.MessageEmbed().setTitle(`Status for PR #${pr_number}`).setURL(pr.html_url);
let color = 'GREEN' as discord.ColorResolvable;
statuses.check_runs.forEach((run: any) => {
msg.addField(`${run.name}`, `**[${run.status} ${run.conclusion}](${run.html_url})**`);
@ -25,7 +25,7 @@ export function command(message: discord.Message) {
msg.setColor(color);
await message.channel.send({ embeds: [msg] });
}).catch(async () => {
await message.channel.send('I wasn\'t able to get the status of that PR...')
await message.channel.send('I wasn\'t able to get the status of that PR...');
});
}).catch(async () => {
await message.channel.send('No such PR.');

View File

@ -13,7 +13,7 @@ const logger = winston.createLogger({
handleExceptions: true
})
],
exitOnError: true,
exitOnError: true
});
// Setup logging for LogDNA cloud logging.

View File

@ -1,6 +1,4 @@
// Check for environmental variables.
require('checkenv').check();
import discord = require('discord.js');
import path = require('path');
import fs = require('fs');
@ -10,6 +8,8 @@ import state from './state';
import * as data from './data';
import { IModule, ITrigger } from './models/interfaces';
require('checkenv').check();
interface IModuleMap {
[name: string]: IModule;
}
@ -45,8 +45,8 @@ client.on('ready', async () => {
if (!process.env.DISCORD_LOG_CHANNEL || !process.env.DISCORD_MSGLOG_CHANNEL) {
throw new Error('DISCORD_LOG_CHANNEL or DISCORD_MSGLOG_CHANNEL not defined.');
}
let logChannel = await client.channels.fetch(process.env.DISCORD_LOG_CHANNEL) as discord.TextChannel;
let msglogChannel = await client.channels.fetch(process.env.DISCORD_MSGLOG_CHANNEL) as discord.TextChannel;
const logChannel = await client.channels.fetch(process.env.DISCORD_LOG_CHANNEL) as discord.TextChannel;
const msglogChannel = await client.channels.fetch(process.env.DISCORD_MSGLOG_CHANNEL) as discord.TextChannel;
if (!logChannel.send) throw new Error('DISCORD_LOG_CHANNEL is not a text channel!');
if (!msglogChannel.send) throw new Error('DISCORD_MSGLOG_CHANNEL is not a text channel!');
state.logChannel = logChannel;
@ -69,22 +69,21 @@ client.on('disconnect', () => {
});
client.on('guildMemberAdd', async (member) => {
if (process.env.DISCORD_RULES_ROLE)
await member.roles.add(process.env.DISCORD_RULES_ROLE);
if (process.env.DISCORD_RULES_ROLE) { await member.roles.add(process.env.DISCORD_RULES_ROLE); }
});
client.on('messageDelete', async (message) => {
const AllowedRoles = ['Administrators', 'Moderators', 'Team', 'Developer', 'Support', 'VIP'];
let authorRoles = message.member?.roles?.cache?.map(x => x.name);
const authorRoles = message.member?.roles?.cache?.map(x => x.name);
if (!authorRoles) {
logger.error(`Unable to get the roles for ${message.author}`);
return;
}
if (!findArray(authorRoles, AllowedRoles)) {
let parent = (message.channel as discord.TextChannel).parent;
const parent = (message.channel as discord.TextChannel).parent;
if (parent && IsIgnoredCategory(parent.name) === false) {
if (((message.content && message.content.startsWith('.') === false) || (message.attachments.size > 0)) && message.author?.bot === false) {
let messageAttachment = message.attachments.first()?.proxyURL
const messageAttachment = message.attachments.first()?.proxyURL;
const deletionEmbed = new discord.MessageEmbed()
.setAuthor(message.author?.tag, message.author?.displayAvatarURL())
@ -93,9 +92,9 @@ client.on('messageDelete', async (message) => {
.setTimestamp()
.setColor('RED');
if (messageAttachment) deletionEmbed.setImage(messageAttachment)
if (messageAttachment) deletionEmbed.setImage(messageAttachment);
let userInfo = `${message.author?.toString()} (${message.author?.username}) (${message.author})`
const userInfo = `${message.author?.toString()} (${message.author?.username}) (${message.author})`;
await state.msglogChannel?.send({ content: userInfo, embeds: [deletionEmbed] });
logger.info(`${message.author?.username} ${message.author} deleted message: ${message.cleanContent}.`);
@ -106,18 +105,18 @@ client.on('messageDelete', async (message) => {
client.on('messageUpdate', async (oldMessage, newMessage) => {
const AllowedRoles = ['Administrators', 'Moderators', 'Team', 'Developer', 'Support', 'VIP'];
let authorRoles = oldMessage.member?.roles?.cache?.map(x => x.name);
const authorRoles = oldMessage.member?.roles?.cache?.map(x => x.name);
if (!authorRoles) {
logger.error(`Unable to get the roles for ${oldMessage.author}`);
return;
}
if (!findArray(authorRoles, AllowedRoles)) {
let parent = (oldMessage.channel as discord.TextChannel).parent;
const parent = (oldMessage.channel as discord.TextChannel).parent;
if (parent && IsIgnoredCategory(parent.name) === false) {
const oldM = oldMessage.cleanContent || '<no content>';
const newM = newMessage.cleanContent;
if (oldMessage.content !== newMessage.content && oldM && newM) {
let messageAttachment = oldMessage.attachments.first()?.proxyURL
const messageAttachment = oldMessage.attachments.first()?.proxyURL;
const editedEmbed = new discord.MessageEmbed()
.setAuthor(oldMessage.author?.tag || '<unknown>', oldMessage.author?.displayAvatarURL())
@ -127,9 +126,9 @@ client.on('messageUpdate', async (oldMessage, newMessage) => {
.setTimestamp()
.setColor('GREEN');
if (messageAttachment) editedEmbed.setImage(messageAttachment)
if (messageAttachment) editedEmbed.setImage(messageAttachment);
let userInfo = `${oldMessage.author?.toString()} (${oldMessage.author?.username}) (${oldMessage.author})`
const userInfo = `${oldMessage.author?.toString()} (${oldMessage.author?.username}) (${oldMessage.author})`;
await state.msglogChannel?.send({ content: userInfo, embeds: [editedEmbed] });
logger.info(`${oldMessage.author?.username} ${oldMessage.author} edited message from: ${oldM} to: ${newM}.`);
@ -151,7 +150,7 @@ client.on('messageCreate', async (message) => {
logger.verbose(`${message.author.username} ${message.author} [Channel: ${(message.channel as discord.TextChannel).name} ${message.channel}]: ${message.content}`);
let authorRoles = message.member?.roles?.cache?.map(x => x.name);
const authorRoles = message.member?.roles?.cache?.map(x => x.name);
if (message.channel.id === process.env.DISCORD_MEDIA_CHANNEL && !message.author.bot) {
const AllowedMediaRoles = ['Administrators', 'Moderators', 'Team', 'VIP'];
@ -187,7 +186,7 @@ client.on('messageCreate', async (message) => {
const cmd = message.content.split(' ', 1)[0].slice(1);
// Check by the name of the command.
let cachedModule = cachedModules[`${cmd.toLowerCase()}`];
const cachedModule = cachedModules[`${cmd.toLowerCase()}`];
let quoteResponse = null;
// Check by the quotes in the configuration.
if (!cachedModule) quoteResponse = state.responses.quotes[cmd];
@ -208,13 +207,12 @@ client.on('messageCreate', async (message) => {
await message.delete();
try {
if (!!cachedModule) {
if (cachedModule) {
await cachedModule.command(message);
} else if (cachedModules['quote']) {
await cachedModules['quote'].command(message, quoteResponse?.reply);
} else if (cachedModules.quote) {
await cachedModules.quote.command(message, quoteResponse?.reply);
}
} catch (err) { logger.error(err); }
} else if (message.author.bot === false) {
// This is a normal channel message.
cachedTriggers.forEach(async function (trigger) {

View File

@ -12,4 +12,4 @@ export async function execute(message: discord.Message) {
logger.info(`${message.author.toString()} tagged ${count} users in ${message.channel.toString()}`);
state.logChannel?.send(`Ping bomb detected in ${message.channel.toString()} by ${message.author.toString()}`);
await ban(message.author, message.author, message.guild);
};
}