update discord adapter for new interface definition

This commit is contained in:
mightypanders 2021-11-13 20:24:48 +01:00
parent 25177b64ff
commit ef4bb487df

View File

@ -55,28 +55,21 @@ export default class DiscordAdapter {
await interaction.reply(result)
}
public async removeUser(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
const discordUser = interaction.user
if (!discordUser.username || discordUser.username == "") {
await interaction.reply(`This user does not seem to have a username, can't delete`)
}
else {
registration.removeUser(discordUser.username)
const discordUser: GuildMember = <GuildMember>interaction.member
registration.removeUser(discordUser)
await interaction.reply(`User has been removed`)
}
return
}
public async registerUser(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
const discordUser = interaction.user
const discordUser: GuildMember = <GuildMember>interaction.member
const steamNameToRegister = interaction.options.getString('steamname')
if (!discordUser.username || discordUser.username == "") {
await interaction.reply(`This user does not seem to have a username, can't register`)
}
else if (!steamNameToRegister) {
console.dir(discordUser)
if (!steamNameToRegister) {
await interaction.reply(`No steam name supplied, can't register`)
}
else {
registration.register(discordUser.username, steamNameToRegister)
await interaction.reply(`This should register user ${discordUser.username} with id ${discordUser.id} to use steamname: ${steamNameToRegister}`)
registration.register(discordUser, steamNameToRegister)
await interaction.reply(`This should register user ${discordUser.user.username} with id ${discordUser.user.id} to use steamname: ${steamNameToRegister}`)
}
return
}
@ -91,13 +84,9 @@ export default class DiscordAdapter {
return
}
public async show(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
const discordUser = interaction.user
if (!discordUser.username || discordUser.username == "") {
await interaction.reply(`This user does not seem to have a username, can't search`)
} else {
const result = registration.getNameRegisteredForDiscordUser(discordUser.username)
const discordUser: GuildMember = <GuildMember>interaction.member
const result = registration.getNameRegisteredForDiscordUser(discordUser)
await interaction.reply(JSON.stringify(result, null, 2))
}
return
}