-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add commands for enabling/disabling voice commands and automatic join…
…ing (#34) Co-authored-by: sweep-ai[bot] <128439645+sweep-ai[bot]@users.noreply.github.com> Co-authored-by: Lassi Säike <lassisaike11@gmail.com>
- Loading branch information
1 parent
3874125
commit 3252073
Showing
6 changed files
with
316 additions
and
10 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src_modules/voice_commands/commands/DisableAutoJoinCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Command, IExecutionContext } from "../../.."; | ||
import VoiceCommandsModule from ".."; | ||
import { autoJoinDisabledPhrase, autoJoinAlreadyDisabledPhrase } from "../phrases"; | ||
|
||
export class DisableAutoJoinCommand extends Command<[]> { | ||
private voiceCommandsModule: VoiceCommandsModule; | ||
|
||
public constructor(voiceCommandsModule: VoiceCommandsModule) { | ||
super( | ||
{ | ||
allowedPrivileges: ["admin"], | ||
author: "extcord", | ||
description: "Disable automatic joining", | ||
globalAliases: ["disableautojoin"], | ||
name: "disableautojoin", | ||
}, | ||
[], | ||
); | ||
|
||
this.voiceCommandsModule = voiceCommandsModule; | ||
} | ||
|
||
public async execute(context: IExecutionContext<[]>) { | ||
const guild = context.guild; | ||
|
||
if (await this.voiceCommandsModule.autoJoinEnabledConfigEntry.guildGet(guild)) { | ||
await this.voiceCommandsModule.autoJoinEnabledConfigEntry.guildSet(guild, false); | ||
return context.respond(autoJoinDisabledPhrase, {}); | ||
} else { | ||
return context.respond(autoJoinAlreadyDisabledPhrase, {}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Command, IExecutionContext } from "../../.."; | ||
import VoiceCommandsModule from ".."; | ||
import { voiceCommandsDisabledPhrase, voiceCommandsAlreadyDisabledPhrase } from "../phrases"; | ||
|
||
export class DisableCommand extends Command<[]> { | ||
private voiceCommandsModule: VoiceCommandsModule; | ||
|
||
public constructor(voiceCommandsModule: VoiceCommandsModule) { | ||
super( | ||
{ | ||
allowedPrivileges: ["admin"], | ||
author: "extcord", | ||
description: "Disable voice commands", | ||
globalAliases: [], | ||
name: "disable", | ||
}, | ||
[], | ||
); | ||
|
||
this.voiceCommandsModule = voiceCommandsModule; | ||
} | ||
|
||
public async execute(context: IExecutionContext<[]>) { | ||
const guild = context.guild; | ||
|
||
if (await this.voiceCommandsModule.voiceCommandsEnabledConfigEntry.guildGet(guild)) { | ||
await this.voiceCommandsModule.voiceCommandsEnabledConfigEntry.guildSet(guild, false); | ||
return context.respond(voiceCommandsDisabledPhrase, {}); | ||
} else { | ||
return context.respond(voiceCommandsAlreadyDisabledPhrase, {}); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src_modules/voice_commands/commands/EnableAutoJoinCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Command, IExecutionContext } from "../../.."; | ||
import VoiceCommandsModule from ".."; | ||
import { autoJoinEnabledPhrase, autoJoinAlreadyEnabledPhrase } from "../phrases"; | ||
|
||
export class EnableAutoJoinCommand extends Command<[]> { | ||
private voiceCommandsModule: VoiceCommandsModule; | ||
|
||
public constructor(voiceCommandsModule: VoiceCommandsModule) { | ||
super( | ||
{ | ||
allowedPrivileges: ["admin"], | ||
author: "extcord", | ||
description: "Enable automatic joining", | ||
globalAliases: ["enableautojoin"], | ||
name: "enableautojoin", | ||
}, | ||
[], | ||
); | ||
|
||
this.voiceCommandsModule = voiceCommandsModule; | ||
} | ||
|
||
public async execute(context: IExecutionContext<[]>) { | ||
const guild = context.guild; | ||
|
||
if (await this.voiceCommandsModule.autoJoinEnabledConfigEntry.guildGet(guild)) { | ||
return context.respond(autoJoinAlreadyEnabledPhrase, {}); | ||
} | ||
|
||
await this.voiceCommandsModule.autoJoinEnabledConfigEntry.guildSet(guild, true); | ||
return context.respond(autoJoinEnabledPhrase, {}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Command, IExecutionContext } from "../../.."; | ||
import VoiceCommandsModule from ".."; | ||
import { voiceCommandsAlreadyEnabledPhrase, voiceCommandsEnabledPhrase, voiceCommandsNotSupportedPhrase } from "../phrases"; | ||
|
||
export class EnableCommand extends Command<[]> { | ||
private voiceCommandsModule: VoiceCommandsModule; | ||
|
||
public constructor(voiceCommandsModule: VoiceCommandsModule) { | ||
super( | ||
{ | ||
allowedPrivileges: ["admin"], | ||
author: "extcord", | ||
description: "Enable voice commands", | ||
globalAliases: [], | ||
name: "enable", | ||
}, | ||
[], | ||
); | ||
|
||
this.voiceCommandsModule = voiceCommandsModule; | ||
} | ||
|
||
public async execute(context: IExecutionContext<[]>) { | ||
const guild = context.guild; | ||
|
||
if (await this.voiceCommandsModule.voiceCommandsEnabledConfigEntry.guildGet(guild)) { | ||
return context.respond(voiceCommandsAlreadyEnabledPhrase, {}); | ||
} | ||
|
||
const backendLanguage = this.voiceCommandsModule.backendLanguageIdPhrase.get(context.language); | ||
|
||
if (backendLanguage === undefined || backendLanguage === "") { | ||
return context.respond(voiceCommandsNotSupportedPhrase, {});; | ||
} | ||
|
||
await this.voiceCommandsModule.voiceCommandsEnabledConfigEntry.guildSet(guild, true); | ||
return context.respond(voiceCommandsEnabledPhrase, {}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { MessagePhrase } from "../.."; | ||
|
||
export const voiceCommandsEnabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when voice commands are enabled", | ||
name: "voiceCommandsEnabled", | ||
}, | ||
"Voice commands enabled.", | ||
{ | ||
timestamp: false, | ||
title: "Voice commands enabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const voiceCommandsDisabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when voice commands are disabled", | ||
name: "voiceCommandsDisabled", | ||
}, | ||
"Voice commands disabled.", | ||
{ | ||
timestamp: false, | ||
title: "Voice commands disabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const autoJoinEnabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when automatic joining is enabled", | ||
name: "autoJoinEnabled", | ||
}, | ||
"Automatic joining enabled.", | ||
{ | ||
timestamp: false, | ||
title: "Automatic joining enabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const autoJoinDisabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when automatic joining is disabled", | ||
name: "autoJoinDisabled", | ||
}, | ||
"Automatic joining disabled.", | ||
{ | ||
timestamp: false, | ||
title: "Automatic joining disabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const autoJoinAlreadyDisabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when automatic joining is already disabled", | ||
name: "autoJoinAlreadyDisabled", | ||
}, | ||
"Automatic joining is already disabled.", | ||
{ | ||
timestamp: false, | ||
title: "Automatic joining already disabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const voiceCommandsAlreadyDisabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when voice commands are already disabled", | ||
name: "voiceCommandsAlreadyDisabled", | ||
}, | ||
"Voice commands are already disabled.", | ||
{ | ||
timestamp: false, | ||
title: "Voice commands already disabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const autoJoinAlreadyEnabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when automatic joining is already enabled", | ||
name: "autoJoinAlreadyEnabled", | ||
}, | ||
"Automatic joining is already enabled.", | ||
{ | ||
timestamp: false, | ||
title: "Automatic joining already enabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const voiceCommandsAlreadyEnabledPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when voice commands are already enabled", | ||
name: "voiceCommandsAlreadyEnabled", | ||
}, | ||
"Voice commands are already enabled.", | ||
{ | ||
timestamp: false, | ||
title: "Voice commands already enabled." | ||
}, | ||
{}, | ||
); | ||
|
||
export const voiceCommandsNotSupportedPhrase = new MessagePhrase( | ||
{ | ||
description: "Shown when voice commands are not supported with the language", | ||
name: "voiceCommandsNotSupported", | ||
}, | ||
"Voice commands are not supported with this language.", | ||
{ | ||
timestamp: false, | ||
title: "Voice commands are not supported with this language." | ||
}, | ||
{}, | ||
); |