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
1 changed files with 11 additions and 22 deletions

View File

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