shuffling things around
This commit is contained in:
parent
fa7ae7cbc1
commit
eb19430d37
@ -1,13 +1,24 @@
|
||||
import RegistrationHandler from "./RegistrationHandler"
|
||||
|
||||
export default class MuteHandler {
|
||||
public mute(player: string): boolean {
|
||||
console.log(`Performing mute wizardry on ${player}`)
|
||||
const register = RegistrationHandler.Instance
|
||||
const binding = register.getNameRegisteredForSteamUser(player)
|
||||
console.log(`Performing mute wizardry on ${player}, ${JSON.stringify(binding)}`)
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
public unmute(player: string): boolean {
|
||||
const register = RegistrationHandler.Instance
|
||||
const binding = register.getNameRegisteredForSteamUser(player)
|
||||
console.log(`Performing unmute wizardry on ${player}`)
|
||||
return true
|
||||
}
|
||||
public unmuteAll(): boolean {
|
||||
const register = RegistrationHandler.Instance
|
||||
const binding = register.getAllMappings()
|
||||
|
||||
console.log(`Performing unmute wizardry on all players`)
|
||||
return true
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
export interface userNameBinding {
|
||||
Steam: string,
|
||||
Discord: string
|
||||
}
|
||||
export type Maybe<T> = T | undefined
|
||||
import { Maybe, userNameBinding } from "./interfaces"
|
||||
|
||||
export default class RegistrationHandler {
|
||||
private userRegister: userNameBinding[] = []
|
||||
private static _instance: RegistrationHandler
|
||||
public constructor() {
|
||||
console.log('Setup RegistrationHandler')
|
||||
}
|
||||
public static get Instance() {
|
||||
return this._instance || (this._instance = new this())
|
||||
}
|
||||
|
||||
public register(discordname: string, steamname: string): boolean {
|
||||
const binding: userNameBinding = {
|
||||
@ -27,10 +28,11 @@ export default class RegistrationHandler {
|
||||
}
|
||||
return true
|
||||
}
|
||||
public getAllMappings(): userNameBinding[] { return this.userRegister }
|
||||
public removeUser(discordName: string): void { this.userRegister = this.userRegister.filter(x => x.Discord !== discordName) }
|
||||
public getNameRegisteredForDiscordUser(discordUser: string): Maybe<userNameBinding> { return this.userRegister.find(x => x.Discord == discordUser) }
|
||||
public getNameRegisteredForSteamUser(steamUser: string): Maybe<userNameBinding> { return this.userRegister.find(x => x.Steam == steamUser) }
|
||||
public listRegisteredMembers(): string { return JSON.stringify(this.userRegister) }
|
||||
private printHelpText(): void { }
|
||||
private printHelpText(): string { return "" }
|
||||
private buildHelpText(): string { return "" }
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
import { CommandInteraction } from "discord.js"
|
||||
import { localized_string } from "./interfaces"
|
||||
import RegistrationHandler from "./RegistrationHandler"
|
||||
|
||||
export const reactions = {
|
||||
troll_grin: "U+1F92A",
|
||||
@ -14,12 +12,6 @@ export const commands = {
|
||||
SHOW_FOR_STEAM_COMMAND: "forsteam",
|
||||
SHOW_COMMAND: "show"
|
||||
}
|
||||
export interface discordCommand {
|
||||
name: string,
|
||||
description: string
|
||||
options?: any[]
|
||||
performCommand(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void>
|
||||
}
|
||||
export const msg_strings: localized_string = {
|
||||
greeting: {
|
||||
german: "Ich wurde neugestartet. Bitte registriert euch erneut, falls ihr automatisch gemutet werden wollt :)",
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { REST } from '@discordjs/rest'
|
||||
import { SlashCommandBuilder } from '@discordjs/builders'
|
||||
import { commands, discordCommand } from './constants'
|
||||
import { commands } from './constants'
|
||||
import { Routes } from 'discord-api-types/v9'
|
||||
import { config } from './configuration'
|
||||
import { Client, CommandInteraction, Intents, Interaction } from 'discord.js'
|
||||
import { Client, CommandInteraction, GuildMember, Intents, Interaction } from 'discord.js'
|
||||
import RegistrationHandler from './RegistrationHandler'
|
||||
import { discordCommand } from './interfaces'
|
||||
|
||||
export default class DiscordAdapter {
|
||||
private rest: REST
|
||||
@ -13,7 +14,7 @@ export default class DiscordAdapter {
|
||||
public constructor() {
|
||||
this.rest = new REST({ version: '9' }).setToken(config.token)
|
||||
this.client = new Client({ intents: [Intents.FLAGS.GUILDS] })
|
||||
this.registration = new RegistrationHandler()
|
||||
this.registration = RegistrationHandler.Instance
|
||||
this.setupCallbacks(this.client)
|
||||
this.client.login(config.token)
|
||||
this.registerCommands(this.commandList)
|
||||
@ -40,6 +41,13 @@ export default class DiscordAdapter {
|
||||
}
|
||||
public async echoes(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
||||
const value = interaction.options.getString('input')
|
||||
const member: GuildMember = <GuildMember>interaction.member
|
||||
try {
|
||||
console.log(`Member ${member.user.username} mute state: ${member.voice.mute}`)
|
||||
member.voice.setMute(!member.voice.mute, "test")
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
await interaction.reply(`This should be an echo: ${value}`)
|
||||
}
|
||||
public async listUsers(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void> {
|
||||
|
@ -1,3 +1,7 @@
|
||||
import { CommandInteraction } from "discord.js"
|
||||
import RegistrationHandler from "./RegistrationHandler"
|
||||
|
||||
export type Maybe<T> = T | undefined
|
||||
export interface Player {
|
||||
name: string
|
||||
}
|
||||
@ -8,3 +12,13 @@ export interface localized_string {
|
||||
english: string
|
||||
}
|
||||
}
|
||||
export interface userNameBinding {
|
||||
Steam: string,
|
||||
Discord: string
|
||||
}
|
||||
export interface discordCommand {
|
||||
name: string,
|
||||
description: string
|
||||
options?: any[]
|
||||
performCommand(interaction: CommandInteraction, registration: RegistrationHandler): Promise<void>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user