convert indentation to tabs

This commit is contained in:
Oliver-Akins 2021-12-02 13:36:13 -06:00
parent f8910e4f30
commit 7ef7e3c3dc
22 changed files with 1985 additions and 765 deletions

View file

@ -15,115 +15,115 @@ const Eris = require("eris");
export const run_discord = (): void => {
const config: config = LOAD_CONFIG();
const config: config = LOAD_CONFIG();
let bot = new Eris(config.DEV ? config.discord.DEV_TOKEN : config.discord.OAUTH_TOKEN);
let bot = new Eris(config.DEV ? config.discord.DEV_TOKEN : config.discord.OAUTH_TOKEN);
bot.on("ready", () => {
log({ msg: `* Connected to Discord gateway` });
});
bot.on("ready", () => {
log({ msg: `* Connected to Discord gateway` });
});
// Message handler
bot.on("messageCreate", (msg: any) => {
try {
// Message handler
bot.on("messageCreate", (msg: any) => {
try {
// Ensure message to parse
if (msg.content.length === 0) { return; };
// Ensure message to parse
if (msg.content.length === 0) { return; };
// SECTION: Exit conditions
// SECTION: Exit conditions
// NOTE: Ensure not a system message
if (msg.type !== 0) { return; }
// NOTE: Ensure not a system message
if (msg.type !== 0) { return; }
// NOTE: Ensure channel type is GUILD_TEXT
else if (msg.channel.type !== 0) { return; }
// NOTE: Ensure channel type is GUILD_TEXT
else if (msg.channel.type !== 0) { return; }
// NOTE: Ensure not a webhook or Clyde
else if (msg.author.discriminator === "0000") { return; }
// NOTE: Ensure not a webhook or Clyde
else if (msg.author.discriminator === "0000") { return; }
// NOTE: Ensure not a bot
else if (msg.member.bot) { return; }
// NOTE: Ensure not a bot
else if (msg.member.bot) { return; }
// !SECTION: Exit conditions
// !SECTION: Exit conditions
var is_mod = msg.member.roles.filter(
(x: string) => { return config.discord.MOD_ROLES.includes(x); }
).length > 0;
var is_admin = config.discord.ADMIN.includes(msg.member.id);
var is_mod = msg.member.roles.filter(
(x: string) => { return config.discord.MOD_ROLES.includes(x); }
).length > 0;
var is_admin = config.discord.ADMIN.includes(msg.member.id);
var level = PERM.ALL;
if (is_mod) { level = PERM.MOD; };
if (is_admin) { level = PERM.ADMIN; };
var level = PERM.ALL;
if (is_mod) { level = PERM.MOD; };
if (is_admin) { level = PERM.ADMIN; };
var response: string | void = HANDLE_MESSAGE({
channel: `Discord:${msg.member.guild.id}`,
level: level,
message: msg.content.trim().replace(/\n/g, ""),
source: "Discord",
user: msg.author.username,
cooldown: true,
test: false
});
var response: string | void = HANDLE_MESSAGE({
channel: `Discord:${msg.member.guild.id}`,
level: level,
message: msg.content.trim().replace(/\n/g, ""),
source: "Discord",
user: msg.author.username,
cooldown: true,
test: false
});
// NOTE: Ensure response isn't null
if (response !== null) {
// NOTE: Ensure response isn't null
if (response !== null) {
// NOTE: Reply with string
bot.createMessage(msg.channel.id, response)
};
// NOTE: Reply with string
bot.createMessage(msg.channel.id, response)
};
}
}
// SECTION: Error Handling
catch (error) {
log_error({
"embeds": [
{
"title": `${error.name}`,
"color": 13238272,
"description": `**Error Message:**\n\`\`\`\n${error.message}\n\`\`\``,
"fields": [
{
"name": "**Message Context:**",
"value": `\`\`\`\n${JSON.stringify(msg, null, 2)}\n\`\`\``
},
{
"name": "**Message Content:**",
"value": `\`\`\`json\n${msg.content}\`\`\``
},
{
"name": "**Is Mod:**",
"value": `\`${is_mod}\``,
"inline": true
},
{
"name": "**Is Admin:**",
"value": `\`${is_admin}\``,
"inline": true
},
{
"name": "**Channel:**",
"value": `\`${msg.channel.name}\``,
"inline": true
},
{
"name": "Source",
"value": "Discord",
"inline": true
}
]
}
]
});
};
// !SECTION: Error Handling
});
// SECTION: Error Handling
catch (error) {
log_error({
"embeds": [
{
"title": `${error.name}`,
"color": 13238272,
"description": `**Error Message:**\n\`\`\`\n${error.message}\n\`\`\``,
"fields": [
{
"name": "**Message Context:**",
"value": `\`\`\`\n${JSON.stringify(msg, null, 2)}\n\`\`\``
},
{
"name": "**Message Content:**",
"value": `\`\`\`json\n${msg.content}\`\`\``
},
{
"name": "**Is Mod:**",
"value": `\`${is_mod}\``,
"inline": true
},
{
"name": "**Is Admin:**",
"value": `\`${is_admin}\``,
"inline": true
},
{
"name": "**Channel:**",
"value": `\`${msg.channel.name}\``,
"inline": true
},
{
"name": "Source",
"value": "Discord",
"inline": true
}
]
}
]
});
};
// !SECTION: Error Handling
});
bot.connect();
bot.connect();
};