Skip to content
Snippets Groups Projects
Commit 5cdf88a6 authored by Joona Kytöniemi's avatar Joona Kytöniemi :sunglasses:
Browse files

Updates

parent ef933849
No related branches found
No related tags found
No related merge requests found
Pipeline #62737 failed
......@@ -3,19 +3,22 @@ import dotenv from 'dotenv';
import InteractionCreate from './listeners/InteractionCreate';
import Ready from './listeners/ReadyListener';
import {StartupTimer} from './utils/StartupTimer';
import {Timer} from './utils/Timer';
dotenv.config();
const timer = new StartupTimer(Date.now());
export const DEBUG_MODE : boolean = true; // TODO: define this in future config json
DEBUG_MODE ? console.log('Ramsay is running in debug mode! (this currently has no effect)') : null;
const startupTimer : Timer = new Timer(Date.now());
console.log('Ramsay is warming up...');
const token = process.env.DISCORD_TOKEN || 'Missing token, check .env-file.';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const token : string = process.env.DISCORD_TOKEN || 'Missing token, check .env-file.';
const client : Client = new Client({ intents: [GatewayIntentBits.Guilds] });
Ready(client);
InteractionCreate(client);
client.login(token);
console.log(`Ramsay has warmed up, took ${timer.getTookMillis(Date.now())}ms!`);
\ No newline at end of file
console.log(`Ramsay has warmed up, took ${startupTimer.getTookMillis(Date.now())}ms!`);
\ No newline at end of file
import {InsultCommand} from './InsultCommand';
import {MenuCommand} from './MenuCommand';
import {Command} from '../interfaces/Command';
import {DEBUG_MODE} from '../Bot';
export const Commands: Command[] = [InsultCommand];
\ No newline at end of file
const isDebug : boolean = DEBUG_MODE;
export const Commands : Command[] = [InsultCommand, MenuCommand];
......@@ -20,6 +20,7 @@ export const InsultCommand: Command = {
run: async (client: Client, interaction: CommandInteraction) => {
const content = insults[getRandomInt(0, insults.length-1)];
await interaction.followUp({
ephemeral: false,
content
......
import axios from 'axios';
import {Client, CommandInteraction} from 'discord.js';
import {Command} from '../interfaces/Command';
export const MenuCommand: Command = {
name: 'menu',
description: 'Fetches the menu of any restaurant that you desire (as long it\'s a student restaurant in Turku)',
type: 1, // CHAT_INPUT
options: [
{
name: 'today',
description: 'What\'s on the menu today?',
type: 1,
},
{
name: 'week',
description: 'Okay',
type: 1
}
],
run: async (client: Client, interaction: CommandInteraction) => {
const content = 'No.'; // no functionality yet
let messageContent : string = '';
switch (interaction.options.data[0].name) {
case 'today':
axios.get('http://127.0.0.1:5000/restaurants/').then(
r => {
console.log(r.data);
for (const val in r.data) {
console.log(val)
}
}
);
break;
case 'week':
messageContent += 'I wouldn\'t know, I just work here.';
break;
}
if (messageContent === '') {
messageContent += 'I tried to get the data but I couldn\'t. Not my fault bro.';
}
await interaction.followUp({
ephemeral: false,
content
content: messageContent
});
}
};
\ No newline at end of file
import { ChatInputApplicationCommandData, Client, CommandInteraction } from 'discord.js';
import {ApplicationCommandOptionData, ChatInputApplicationCommandData, Client, CommandInteraction} from 'discord.js';
export interface Command extends ChatInputApplicationCommandData {
run: (client: Client, interaction: CommandInteraction) => void;
run: (client: Client, interaction: CommandInteraction, options?: ApplicationCommandOptionData) => void;
}
\ No newline at end of file
import {Client, CommandInteraction, Interaction} from 'discord.js';
import {Commands} from '../cmd/Commands';
export default (client: Client): void => {
client.on('interactionCreate', async (interaction: Interaction) => {
if (interaction.isCommand()) {
......
import {Locale} from 'discord.js';
export class EventData {
constructor(
public lang: Locale,
......
export class StartupTimer {
export class Timer {
private readonly start_ms : number;
private end_ms : number;
constructor(start_ms : number) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment