Version 3.0 sortie, fusion avec JujulBot
This commit is contained in:
@@ -1,35 +1,45 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction, AutocompleteInteraction, EmbedBuilder, inlineCode } from 'discord.js'
|
||||
import * as AMP from '../../utils/amp'
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction, AutocompleteInteraction, ApplicationCommandOptionChoiceData, EmbedBuilder, inlineCode, PermissionFlagsBits } from 'discord.js'
|
||||
import dbGuild from '../../schemas/guild'
|
||||
import * as AMP from '../../utils/amp'
|
||||
|
||||
interface ListInstancesResult {
|
||||
status: string
|
||||
data: [
|
||||
Host: {
|
||||
AvailableInstances: any[]
|
||||
FriendlyName: string
|
||||
}
|
||||
]
|
||||
}
|
||||
interface InstanceFields {
|
||||
name: string
|
||||
value: string
|
||||
inline: boolean
|
||||
}
|
||||
|
||||
interface failData {
|
||||
Title: string
|
||||
Message: string
|
||||
interface InstanceResult {
|
||||
status: string
|
||||
data: [
|
||||
Host
|
||||
]
|
||||
}
|
||||
interface errorData {
|
||||
error_code: string
|
||||
interface Host {
|
||||
AvailableInstances: Instance[]
|
||||
FriendlyName: string
|
||||
}
|
||||
interface Instance {
|
||||
InstanceID: string
|
||||
FriendlyName: string
|
||||
Running: boolean
|
||||
Module: string
|
||||
Port: number
|
||||
}
|
||||
interface FailMsgData {
|
||||
Title: string
|
||||
Message: string
|
||||
}
|
||||
interface ErrorMsgData {
|
||||
error_code: string
|
||||
}
|
||||
|
||||
function failMsg(data: any) { return `La commande a échouée !\n${inlineCode(`${data.Title}: ${data.Message}`)}` }
|
||||
function errorMsg(data: any) { return `Y'a eu une erreur !\n${inlineCode(`${data.error_code}`)}` }
|
||||
function failMsg(data: FailMsgData) { return `La commande a échouée !\n${inlineCode(`${data.Title}: ${data.Message}`)}` }
|
||||
function errorMsg(data: ErrorMsgData) { return `Y'a eu une erreur !\n${inlineCode(`${data.error_code}`)}` }
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder().setName('amp').setDescription('Accède à mon panel de jeu AMP !')
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('amp')
|
||||
.setDescription('Accède à mon panel de jeu AMP !')
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addSubcommand(subcommand => subcommand.setName('login').setDescription("Connectez-vous avant d'effectuer une autre commande !")
|
||||
.addStringOption(option => option.setName('username').setDescription("Nom d'Utilisateur").setRequired(true))
|
||||
.addStringOption(option => option.setName('password').setDescription('Mot de Passe').setRequired(true))
|
||||
@@ -71,12 +81,12 @@ export default {
|
||||
}
|
||||
else if (session.status === 'error') return interaction.respond([])
|
||||
|
||||
let choices: any = []
|
||||
let choices: ApplicationCommandOptionChoiceData[] = []
|
||||
let result = await AMP.ADSModule.GetInstances(host, sessionID)
|
||||
if (result.status === 'success') {
|
||||
let hosts = result.data.result as any[]
|
||||
let hosts = result.data.result as Host[]
|
||||
hosts.forEach(host => {
|
||||
let instances = host.AvailableInstances as any[]
|
||||
let instances = host.AvailableInstances as Instance[]
|
||||
instances.forEach(instance => {
|
||||
if (instance.FriendlyName.includes(query)) choices.push({ name: `${host.FriendlyName} - ${instance.FriendlyName}`, value: instance.InstanceID })
|
||||
})
|
||||
@@ -105,10 +115,10 @@ export default {
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
let details = {
|
||||
username: interaction.options.getString('username'),
|
||||
password: interaction.options.getString('password'),
|
||||
token: interaction.options.getString('otp') || '',
|
||||
rememberMe: interaction.options.getBoolean('remember')
|
||||
username: interaction.options.getString('username') || '',
|
||||
password: interaction.options.getString('password') || '',
|
||||
rememberMe: interaction.options.getBoolean('remember') || '',
|
||||
token: interaction.options.getString('otp') || ''
|
||||
}
|
||||
|
||||
let result = await AMP.Core.Login(host, details)
|
||||
@@ -146,13 +156,13 @@ export default {
|
||||
|
||||
if (interaction.options.getSubcommandGroup() == 'instances') {
|
||||
if (interaction.options.getSubcommand() == 'list') {
|
||||
let result = await AMP.ADSModule.GetInstances(host, sessionID) as ListInstancesResult
|
||||
let result = await AMP.ADSModule.GetInstances(host, sessionID) as InstanceResult
|
||||
|
||||
if (result.status === 'success') {
|
||||
await interaction.followUp({ content: `${result.data.length} hôte(s) trouvé(s) !` })
|
||||
result.data.forEach(async host => {
|
||||
let fields = [] as InstanceFields[]
|
||||
host.AvailableInstances.forEach(instance => {
|
||||
host.AvailableInstances.forEach((instance: Instance) => {
|
||||
fields.push({
|
||||
name: instance.FriendlyName,
|
||||
value: `**Running:** ${instance.Running}\n**Port:** ${instance.Port}\n**Module:** ${instance.Module}`,
|
||||
@@ -168,8 +178,8 @@ export default {
|
||||
return await interaction.channel?.send({ embeds: [embed] })
|
||||
})
|
||||
}
|
||||
else if (result.status === 'fail') return await interaction.followUp(failMsg(result.data))
|
||||
else if (result.status === 'error') return await interaction.followUp(errorMsg(result.data))
|
||||
else if (result.status === 'fail') return await interaction.followUp(failMsg(result.data as unknown as FailMsgData))
|
||||
else if (result.status === 'error') return await interaction.followUp(errorMsg(result.data as unknown as ErrorMsgData))
|
||||
}
|
||||
else if (interaction.options.getSubcommand() == 'manage') {
|
||||
let instanceID = interaction.options.getString('instance', true)
|
||||
|
||||
37
src/commands/global/boost.ts
Normal file
37
src/commands/global/boost.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { SlashCommandBuilder, EmbedBuilder, ChatInputCommandInteraction, TextChannel, PermissionFlagsBits } from 'discord.js'
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('boost')
|
||||
.setDescription('Tester le boost du serveur !')
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
if (interaction.guild?.id !== '796327643783626782') return interaction.reply({ content: 'Non !' })// Jujul Community
|
||||
let member = interaction.member
|
||||
if (!member) return console.log(`\u001b[1;31m Aucun membre trouvé !`)
|
||||
|
||||
let guild = interaction.guild
|
||||
if (!guild) return console.log(`\u001b[1;31m Aucun serveur trouvé !`)
|
||||
|
||||
let channel = guild.channels.cache.get('924353449930412153') as TextChannel
|
||||
if (!channel) return console.log(`\u001b[1;31m Aucun channel trouvé avec l'id "924353449930412153" !`)
|
||||
|
||||
let boostRole = guild.roles.premiumSubscriberRole
|
||||
if (!boostRole) return console.log(`\u001b[1;31m Aucun rôle de boost trouvé !`)
|
||||
|
||||
if (!guild.members.me) return console.log(`\u001b[1;31m Je ne suis pas sur le serveur !`)
|
||||
|
||||
let embed = new EmbedBuilder()
|
||||
.setColor(guild.members.me.displayHexColor)
|
||||
.setTitle(`Nouveau boost de ${member.user.username} !`)
|
||||
.setDescription(`
|
||||
Merci à toi pour ce boost.\n
|
||||
Grâce à toi, on a atteint ${guild.premiumSubscriptionCount} boosts !
|
||||
`)
|
||||
.setThumbnail(member.user.avatar)
|
||||
.setTimestamp(new Date())
|
||||
|
||||
await channel.send({ embeds: [embed] })
|
||||
await interaction.reply({ content: 'Va voir dans <#924353449930412153> !' })
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction, EmbedBuilder, APIEmbedField } from 'discord.js'
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction, EmbedBuilder, APIEmbedField, PermissionFlagsBits } from 'discord.js'
|
||||
|
||||
import dbGuildInit from '../../utils/dbGuildInit'
|
||||
import dbGuild from '../../schemas/guild'
|
||||
@@ -23,6 +23,7 @@ export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('database')
|
||||
.setDescription('Communicate with the database')
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addSubcommand(subcommand => subcommand.setName('info').setDescription('Returns information about the current guild'))
|
||||
.addSubcommand(subcommand => subcommand.setName('init').setDescription('Force initialize an entry for the current guild in the database'))
|
||||
.addSubcommand(subcommand => subcommand.setName('edit').setDescription('Modify parameters for the current guild')
|
||||
@@ -44,7 +45,9 @@ export default {
|
||||
.setDescription(`Guild **${guildProfile.guildName}** (ID: ${guildProfile.guildId})`)
|
||||
.setThumbnail(guildProfile.guildIcon as string)
|
||||
.setTimestamp()
|
||||
.addFields(fields as APIEmbedField[])
|
||||
//.addFields(fields as APIEmbedField[])
|
||||
// Limit the number of fields to 25
|
||||
.addFields(fields.slice(0, 25) as APIEmbedField[])
|
||||
return await interaction.reply({ embeds: [embed] })
|
||||
|
||||
} else if (interaction.options.getSubcommand() === 'init') {
|
||||
|
||||
25
src/commands/player/panel.ts
Executable file
25
src/commands/player/panel.ts
Executable file
@@ -0,0 +1,25 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js'
|
||||
import { playerGenerate } from '../../utils/player'
|
||||
import getUptime from '../../utils/getUptime'
|
||||
import { useQueue } from 'discord-player'
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('panel')
|
||||
.setDescription('Générer les infos de la lecture en cours.'),
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
let queue = useQueue(interaction.guild?.id ?? '')
|
||||
if (!queue) return interaction.followUp({ content: 'Aucune file d\'attente en cours, recherche une musique plutôt !' })
|
||||
|
||||
let guild = interaction.guild
|
||||
if (!guild) return await interaction.reply({ content: 'Cette commande n\'est pas disponible en message privé.', ephemeral: true })
|
||||
|
||||
let client = guild.client
|
||||
|
||||
let { embed, components } = await playerGenerate(guild)
|
||||
if (components && embed.data.footer) embed.setFooter({ text: `Uptime: ${getUptime(client.uptime)} \n ${embed.data.footer.text}` })
|
||||
else embed.setFooter({ text: `Uptime: ${getUptime(client.uptime)}` })
|
||||
|
||||
return interaction.reply({ embeds: [embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction, AutocompleteInteraction, GuildMember } from 'discord.js'
|
||||
import { useMainPlayer, useQueue, QueryType } from 'discord-player'
|
||||
|
||||
import dbGuild from '../../schemas/guild'
|
||||
|
||||
export interface TrackSearchResult { name: string, value: string }
|
||||
interface TrackSearchResult { name: string, value: string }
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
|
||||
19
src/commands/player/queue.ts
Executable file
19
src/commands/player/queue.ts
Executable file
@@ -0,0 +1,19 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js'
|
||||
import { useQueue } from 'discord-player'
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('queue')
|
||||
.setDescription("Récupérer la file d'attente."),
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
let queue = useQueue(interaction.guild?.id ?? '')
|
||||
if (!queue) return interaction.reply({ content: 'Aucune file d\'attente en cours, recherche une musique plutôt !' })
|
||||
if (!queue.currentTrack) return interaction.reply({ content: 'Aucune musique en cours de lecture.' })
|
||||
|
||||
let track = `[${queue.currentTrack.title}](${queue.currentTrack.url})`
|
||||
let tracks = queue.tracks.map((track, index) => { return `${index + 1}. [${track.title}](${track.url})` })
|
||||
if (tracks.length === 0) return interaction.reply({ content: `Lecture en cours : ${track} \nAucune musique dans la file d'attente.` })
|
||||
|
||||
return interaction.reply({ content: `Lecture en cours : ${track} \nFile d'attente actuelle : \n${tracks.join('\n')}` })
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,19 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction, EmbedBuilder, Message, inlineCode } from 'discord.js'
|
||||
import https from 'https'
|
||||
import * as Freebox from '../../utils/freebox'
|
||||
import dbGuild from '../../schemas/guild'
|
||||
import crypto from 'crypto'
|
||||
import https from 'https'
|
||||
//import path from 'path'
|
||||
//import fs from 'fs'
|
||||
|
||||
import * as Freebox from '../../utils/freebox'
|
||||
import dbGuild from '../../schemas/guild'
|
||||
interface ReturnMsgData {
|
||||
status: string
|
||||
error_code?: string
|
||||
Title?: string
|
||||
Message?: string
|
||||
}
|
||||
|
||||
|
||||
function returnMsg(result: any) {
|
||||
function returnMsg(result: ReturnMsgData) {
|
||||
if (result.status === 'fail') return `La commande a échouée !\n${inlineCode(`${result.Title}: ${result.Message}`)}`
|
||||
if (result.status === 'error') return `Y'a eu une erreur !\n${inlineCode(`${result.error_code}`)}`
|
||||
}
|
||||
Reference in New Issue
Block a user