can list all events
This commit is contained in:
parent
51c5e79ffc
commit
38032a180f
|
@ -1,16 +1,17 @@
|
||||||
import { REST } from '@discordjs/rest'
|
import { REST } from '@discordjs/rest'
|
||||||
import { SlashCommandBuilder } from '@discordjs/builders'
|
|
||||||
import { commands } from './constants'
|
import { commands } from './constants'
|
||||||
import { Routes } from 'discord-api-types/v9'
|
import { Routes } from 'discord-api-types/v9'
|
||||||
import { config } from './configuration'
|
import { config } from './configuration'
|
||||||
import { Client, CommandInteraction, GuildMember, Intents, Interaction } from 'discord.js'
|
import { Client, Collection, CommandInteraction, GuildMember, GuildScheduledEvent, GuildScheduledEventManager, Intents, Snowflake } from 'discord.js'
|
||||||
import RegistrationHandler from './RegistrationHandler'
|
import RegistrationHandler from './RegistrationHandler'
|
||||||
import { discordCommand } from './interfaces'
|
import { discordCommand } from './interfaces'
|
||||||
|
import eventHandler from './eventHandler'
|
||||||
|
|
||||||
export default class DiscordAdapter {
|
export default class DiscordAdapter {
|
||||||
private rest: REST
|
private rest: REST
|
||||||
private client: Client
|
private client: Client
|
||||||
private registration: RegistrationHandler
|
private registration: RegistrationHandler
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
this.rest = new REST({ version: '9' }).setToken(config.token)
|
this.rest = new REST({ version: '9' }).setToken(config.token)
|
||||||
this.client = new Client({ intents: [Intents.FLAGS.GUILDS] })
|
this.client = new Client({ intents: [Intents.FLAGS.GUILDS] })
|
||||||
|
@ -83,12 +84,22 @@ export default class DiscordAdapter {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
public async show(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
public async showNext(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
||||||
const discordUser: GuildMember = <GuildMember>interaction.member
|
const discordUser: GuildMember = <GuildMember>interaction.member
|
||||||
const result = registration.getNameRegisteredForDiscordUser(discordUser)
|
const result = registration.getNameRegisteredForDiscordUser(discordUser)
|
||||||
await interaction.reply(JSON.stringify(result, null, 2))
|
await interaction.reply(JSON.stringify(result, null, 2))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
public async listEvents(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
||||||
|
const guild = interaction.guild
|
||||||
|
if (!guild) {
|
||||||
|
console.log(`There is no guild here`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = new eventHandler().listAllEvents(guild)
|
||||||
|
await interaction.reply(output)
|
||||||
|
}
|
||||||
|
|
||||||
public commandList: discordCommand[] = [
|
public commandList: discordCommand[] = [
|
||||||
{
|
{
|
||||||
|
@ -105,45 +116,14 @@ export default class DiscordAdapter {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: commands.LIST_COMMAND,
|
name: "shownext",
|
||||||
description: "Lists all registerd users",
|
description: "Shows next Events",
|
||||||
performCommand: this.listUsers
|
performCommand: this.showNext
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: commands.REMOVE_COMMAND,
|
name: "listevents",
|
||||||
description: "Remove the mapping for this discord user",
|
description: "Lists all Events",
|
||||||
performCommand: this.removeUser
|
performCommand: this.listEvents
|
||||||
},
|
|
||||||
{
|
|
||||||
name: commands.REGISTER_COMMAND,
|
|
||||||
description: "Register the senders discord name for a supplied steam name",
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'steamname',
|
|
||||||
description: 'The steamname that should be registered',
|
|
||||||
required: true,
|
|
||||||
type: 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
performCommand: this.registerUser
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: commands.SHOW_FOR_STEAM_COMMAND,
|
|
||||||
description: "Show the discord that's registered for a steam name",
|
|
||||||
performCommand: this.showForSteam,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'steamname',
|
|
||||||
description: 'The steamname that should be searched',
|
|
||||||
required: true,
|
|
||||||
type: 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: commands.SHOW_COMMAND,
|
|
||||||
description: "Show the Steamname that's registered for this discord name",
|
|
||||||
performCommand: this.show
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue