WIP: Format code with Google Typescript formatting guidelines
This commit is contained in:
@@ -1,23 +1,21 @@
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import {ChatInputCommandInteraction, SlashCommandBuilder} from 'discord.js';
|
||||
|
||||
import { Settings } from "./common";
|
||||
import {Settings} from './common';
|
||||
|
||||
import { Nag, CheckIn } from './common';
|
||||
import {Nag, CheckIn} from './common';
|
||||
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName("checkin")
|
||||
.setDescription("Check-in for your daily nag")
|
||||
.addStringOption((option) =>
|
||||
.setName('checkin')
|
||||
.setDescription('Check-in for your daily nag')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("text")
|
||||
.setDescription("Optional description of what you have achieved"),
|
||||
.setName('text')
|
||||
.setDescription('Optional description of what you have achieved'),
|
||||
);
|
||||
|
||||
async function initialize(settings: Settings) {}
|
||||
|
||||
function execute(interaction: ChatInputCommandInteraction) {
|
||||
|
||||
}
|
||||
function execute(interaction: ChatInputCommandInteraction) {}
|
||||
|
||||
export default function () {
|
||||
return {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
Client,
|
||||
SlashCommandBuilder,
|
||||
TextChannel,
|
||||
} from "discord.js";
|
||||
} from 'discord.js';
|
||||
import {
|
||||
Sequelize,
|
||||
Model,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
BOOLEAN,
|
||||
DATE,
|
||||
literal,
|
||||
} from "sequelize";
|
||||
} from 'sequelize';
|
||||
|
||||
export interface Settings {
|
||||
client: Client; // Main Discord client object
|
||||
@@ -63,7 +63,7 @@ export async function initAndSyncTables(sequelize: Sequelize) {
|
||||
type: BOOLEAN,
|
||||
},
|
||||
},
|
||||
{ sequelize },
|
||||
{sequelize},
|
||||
);
|
||||
CheckIn.init(
|
||||
{
|
||||
@@ -76,14 +76,14 @@ export async function initAndSyncTables(sequelize: Sequelize) {
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{ sequelize },
|
||||
{sequelize},
|
||||
);
|
||||
Nag.hasOne(CheckIn, { foreignKey: "nagId" });
|
||||
Nag.hasOne(CheckIn, {foreignKey: 'nagId'});
|
||||
await Nag.sync();
|
||||
await CheckIn.sync();
|
||||
}
|
||||
|
||||
import { Guild, Channel } from "discord.js";
|
||||
import {Guild, Channel} from 'discord.js';
|
||||
|
||||
export class Plugin {
|
||||
settings: Settings;
|
||||
@@ -106,7 +106,7 @@ export class Plugin {
|
||||
|
||||
async triggerNag(nag: Nag) {
|
||||
const client = this.settings.client;
|
||||
const chan = client.channels.cache.get("1234"); // TODO
|
||||
const chan = client.channels.cache.get('1234'); // TODO
|
||||
if (!(chan instanceof TextChannel)) {
|
||||
return; // TODO
|
||||
}
|
||||
@@ -114,16 +114,16 @@ export class Plugin {
|
||||
const failText =
|
||||
nag.failText ??
|
||||
`<@${nag.userId}> didn't complete "${nag.text}". Shame shame!`;
|
||||
const mentionHere = nag.mentionHere ? "<@here> " : "";
|
||||
const mentionHere = nag.mentionHere ? '<@here> ' : '';
|
||||
const msg = `${mentionHere}${failText}`;
|
||||
await chan.send(msg);
|
||||
} catch (error) {
|
||||
console.log("Error while creating Nag:", error); // TODO
|
||||
console.log('Error while creating Nag:', error); // TODO
|
||||
}
|
||||
}
|
||||
|
||||
async loop() {
|
||||
console.debug("nag.js main loop");
|
||||
console.debug('nag.js main loop');
|
||||
// Find all nags where the last check-in was before (next check in) - (24 hours)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,30 +2,30 @@ import {
|
||||
ChatInputCommandInteraction,
|
||||
Client,
|
||||
SlashCommandBuilder,
|
||||
} from "discord.js";
|
||||
import { Sequelize, literal } from "sequelize";
|
||||
} from 'discord.js';
|
||||
import {Sequelize, literal} from 'sequelize';
|
||||
|
||||
import { Nag, CheckIn, Settings } from "./common";
|
||||
import { Chrono } from "chrono-node";
|
||||
import {Nag, CheckIn, Settings} from './common';
|
||||
import {Chrono} from 'chrono-node';
|
||||
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName("nag")
|
||||
.setDescription("Let Blitzcrank nag you every day about something")
|
||||
.addStringOption((option) =>
|
||||
.setName('nag')
|
||||
.setDescription('Let Blitzcrank nag you every day about something')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setRequired(true)
|
||||
.setName("text")
|
||||
.setDescription("What you have to do every day"),
|
||||
.setName('text')
|
||||
.setDescription('What you have to do every day'),
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("failText")
|
||||
.setDescription("Custom message to be broadcast on failure"),
|
||||
.setName('failText')
|
||||
.setDescription('Custom message to be broadcast on failure'),
|
||||
)
|
||||
.addBooleanOption((option) =>
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("mentionHere")
|
||||
.setDescription("Whether to DM you or @ a channel")
|
||||
.setName('mentionHere')
|
||||
.setDescription('Whether to DM you or @ a channel')
|
||||
.setRequired(false),
|
||||
);
|
||||
|
||||
@@ -41,7 +41,7 @@ function lateCheckedInUsers() {
|
||||
async function initialize(settings: Settings) {}
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction) {
|
||||
const text = interaction.options.getString("text");
|
||||
const text = interaction.options.getString('text');
|
||||
if (text === null || text === undefined) {
|
||||
await interaction.reply("Nag can't have a blank `text`, try again.");
|
||||
return;
|
||||
@@ -49,15 +49,15 @@ async function execute(interaction: ChatInputCommandInteraction) {
|
||||
const nag = await Nag.create({
|
||||
userId: interaction.user.id,
|
||||
text: text,
|
||||
failText: interaction.options.getString("failText"),
|
||||
mentionHere: interaction.options.getBoolean("mentionHere") ?? false,
|
||||
failText: interaction.options.getString('failText'),
|
||||
mentionHere: interaction.options.getBoolean('mentionHere') ?? false,
|
||||
});
|
||||
await nag.save();
|
||||
const chrono = new Chrono();
|
||||
const checkIn = chrono.parseDate("today at 9AM");
|
||||
const checkIn = chrono.parseDate('today at 9AM');
|
||||
if (!checkIn) {
|
||||
await interaction.reply(
|
||||
"Internal error while saving your nag. Tell Drew the bot is broken!!!",
|
||||
'Internal error while saving your nag. Tell Drew the bot is broken!!!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,19 +2,16 @@ import {
|
||||
ChatInputCommandInteraction,
|
||||
Client,
|
||||
SlashCommandBuilder,
|
||||
} from "discord.js";
|
||||
import { Sequelize } from "sequelize";
|
||||
|
||||
import { Settings } from './common'
|
||||
} from 'discord.js';
|
||||
import {Sequelize} from 'sequelize';
|
||||
|
||||
import {Settings} from './common';
|
||||
|
||||
const data = new SlashCommandBuilder()
|
||||
.setName("unnag")
|
||||
.setDescription("Remove a nag");
|
||||
.setName('unnag')
|
||||
.setDescription('Remove a nag');
|
||||
|
||||
|
||||
async function initialize(settings: Settings) {
|
||||
}
|
||||
async function initialize(settings: Settings) {}
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction) {
|
||||
return;
|
||||
@@ -24,6 +21,6 @@ export default function (settings: Settings) {
|
||||
return {
|
||||
data,
|
||||
execute,
|
||||
initialize: async() => await initialize(settings),
|
||||
initialize: async () => await initialize(settings),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user