echoes
This commit is contained in:
parent
8f39a001e5
commit
b8930ae74a
@ -1,5 +1,4 @@
|
|||||||
import { REST } from '@discordjs/rest'
|
import { REST } from '@discordjs/rest'
|
||||||
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, Collection, CommandInteraction, GuildMember, GuildScheduledEvent, GuildScheduledEventManager, Intents, Snowflake } from 'discord.js'
|
import { Client, Collection, CommandInteraction, GuildMember, GuildScheduledEvent, GuildScheduledEventManager, Intents, Snowflake } from 'discord.js'
|
||||||
@ -40,57 +39,18 @@ export default class DiscordAdapter {
|
|||||||
interactionCommand.performCommand(interaction, this.registration)
|
interactionCommand.performCommand(interaction, this.registration)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
public async echoes(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
public async showNext(interaction: CommandInteraction): Promise<void> {
|
||||||
const value = interaction.options.getString('input')
|
const guild = interaction.guild
|
||||||
const member: GuildMember = <GuildMember>interaction.member
|
if (!guild) {
|
||||||
try {
|
console.log(`There is no guild here`)
|
||||||
console.log(`Member ${member.user.username} mute state: ${member.voice.mute}`)
|
return
|
||||||
member.voice.setMute(!member.voice.mute, "test")
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
}
|
}
|
||||||
await interaction.reply(`This should be an echo: ${value}`)
|
|
||||||
}
|
const output = new eventHandler().getNextEvent(guild)
|
||||||
public async listUsers(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
await interaction.reply(output)
|
||||||
const result = registration.listRegisteredMembers()
|
|
||||||
await interaction.reply(result)
|
|
||||||
}
|
|
||||||
public async removeUser(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
|
||||||
const discordUser: GuildMember = <GuildMember>interaction.member
|
|
||||||
registration.removeUser(discordUser)
|
|
||||||
await interaction.reply(`User has been removed`)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
public async registerUser(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
public async listEvents(interaction: CommandInteraction): Promise<void> {
|
||||||
const discordUser: GuildMember = <GuildMember>interaction.member
|
|
||||||
const steamNameToRegister = interaction.options.getString('steamname')
|
|
||||||
console.dir(discordUser)
|
|
||||||
if (!steamNameToRegister) {
|
|
||||||
await interaction.reply(`No steam name supplied, can't register`)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
registration.register(discordUser, steamNameToRegister)
|
|
||||||
await interaction.reply(`This should register user ${discordUser.user.username} with id ${discordUser.user.id} to use steamname: ${steamNameToRegister}`)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
public async showForSteam(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
|
||||||
const steamName = interaction.options.getString('steamname')
|
|
||||||
if (!steamName) {
|
|
||||||
await interaction.reply(`No steam name supplied, can't search`)
|
|
||||||
} else {
|
|
||||||
const result = registration.getNameRegisteredForSteamUser(steamName)
|
|
||||||
await interaction.reply(JSON.stringify(result, null, 2))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
public async showNext(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
|
||||||
const discordUser: GuildMember = <GuildMember>interaction.member
|
|
||||||
const result = registration.getNameRegisteredForDiscordUser(discordUser)
|
|
||||||
await interaction.reply(JSON.stringify(result, null, 2))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
public async listEvents(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
|
||||||
const guild = interaction.guild
|
const guild = interaction.guild
|
||||||
if (!guild) {
|
if (!guild) {
|
||||||
console.log(`There is no guild here`)
|
console.log(`There is no guild here`)
|
||||||
@ -102,19 +62,6 @@ export default class DiscordAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public commandList: discordCommand[] = [
|
public commandList: discordCommand[] = [
|
||||||
{
|
|
||||||
name: "echo",
|
|
||||||
description: "Echoes a string",
|
|
||||||
performCommand: this.echoes,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'input',
|
|
||||||
description: 'The input that should be echoed',
|
|
||||||
required: true,
|
|
||||||
type: 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "shownext",
|
name: "shownext",
|
||||||
description: "Shows next Events",
|
description: "Shows next Events",
|
||||||
|
@ -5,6 +5,16 @@ export default class eventHandler {
|
|||||||
public constructor() {
|
public constructor() {
|
||||||
console.log('constructed')
|
console.log('constructed')
|
||||||
}
|
}
|
||||||
|
public getNextEvent(guild: Guild): string {
|
||||||
|
const eventManager = guild.scheduledEvents
|
||||||
|
const events = eventManager.cache
|
||||||
|
const sortedEvents = events.sort(function(a, b) { return Number(a.scheduledStartAt) - Number(b.scheduledStartAt) })
|
||||||
|
|
||||||
|
console.log(JSON.stringify(events))
|
||||||
|
console.log(JSON.stringify(sortedEvents))
|
||||||
|
|
||||||
|
return sortedEvents.first()?.toString() ?? ""
|
||||||
|
}
|
||||||
public listAllEvents(guild: Guild): string {
|
public listAllEvents(guild: Guild): string {
|
||||||
|
|
||||||
const eventManager = guild.scheduledEvents
|
const eventManager = guild.scheduledEvents
|
||||||
@ -14,6 +24,7 @@ export default class eventHandler {
|
|||||||
|
|
||||||
for (const e of entries) {
|
for (const e of entries) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
|
output += "\n"
|
||||||
output += e.toString()
|
output += e.toString()
|
||||||
}
|
}
|
||||||
console.log(output)
|
console.log(output)
|
||||||
|
Loading…
Reference in New Issue
Block a user