Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to discordjs v14 #44

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
374 changes: 168 additions & 206 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
},
"homepage": "https://github.com/stefanleminh/ploot#readme",
"dependencies": {
"@discordjs/rest": "^0.4.1",
"discord-api-types": "^0.32.1",
"discord.js": "^13.7.0",
"discord.js": "^14.14.1",
"keyv": "^4.3.2",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.7.1"
Expand All @@ -50,7 +48,7 @@
"ts-migrate": "^0.1.35",
"ts-node": "^10.9.1",
"ts-standard": "^12.0.1",
"typescript": "^4.9.4"
"typescript": "^5.3.3"
},
"standard": {
"env": [
Expand Down
26 changes: 13 additions & 13 deletions src/commands/configure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type CollectorFilter, type CommandInteraction, MessageActionRow, MessageSelectMenu, MessageButton } from 'discord.js'
import { type CollectorFilter, type CommandInteraction, ComponentType, ChannelType, StringSelectMenuBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'
import { type Properties } from '../types/properties.js'
import path from 'path'
import { logging } from '../logging/winston.js'
Expand All @@ -21,35 +21,35 @@ export const command: Command = {
await interaction.deferReply()

const voiceChannels = interaction.guild.channels.cache
.filter(channel => channel.type === 'GUILD_VOICE')
.filter(channel => channel.type === ChannelType.GuildVoice)
.map(channel => ({
label: channel.name,
value: channel.id
}))
const spectatorVc = new MessageSelectMenu()
const spectatorVc = new StringSelectMenuBuilder()
.setCustomId('spectatorVc')
.setPlaceholder('Please specify the lobby VC')
.addOptions(voiceChannels)

const firstTeamVc = new MessageSelectMenu()
const firstTeamVc = new StringSelectMenuBuilder()
.setCustomId('firstTeamVc')
.setPlaceholder('Please specify the first team VC')
.addOptions(voiceChannels)

const secondTeamVc = new MessageSelectMenu()
const secondTeamVc = new StringSelectMenuBuilder()
.setCustomId('secondTeamVc')
.setPlaceholder('Please specify the second team VC')
.addOptions(voiceChannels)

const button = new MessageButton()
const button = new ButtonBuilder()
.setCustomId('submit')
.setLabel('Submit')
.setStyle('PRIMARY')
.setStyle(ButtonStyle.Primary)

const spectatorSelect = new MessageActionRow().addComponents(spectatorVc)
const firstTeamSelect = new MessageActionRow().addComponents(firstTeamVc)
const secondTeamSelect = new MessageActionRow().addComponents(secondTeamVc)
const submitRow = new MessageActionRow().addComponents(button)
const spectatorSelect = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(spectatorVc)
const firstTeamSelect = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(firstTeamVc)
const secondTeamSelect = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(secondTeamVc)
const submitRow = new ActionRowBuilder<ButtonBuilder>().addComponents(button)

const filter: CollectorFilter<any> = i => {
return i.user.id === interaction.user.id
Expand All @@ -58,7 +58,7 @@ export const command: Command = {
const selectCollector = interaction.channel!.createMessageComponentCollector(
{
filter,
componentType: 'SELECT_MENU'
componentType: ComponentType.StringSelect
}
)

Expand Down Expand Up @@ -90,7 +90,7 @@ export const command: Command = {
})

const buttonCollector = interaction.channel!.createMessageComponentCollector(
{ filter, componentType: 'BUTTON' }
{ filter, componentType: ComponentType.Button }
)
buttonCollector.on('collect', async i => {
await interaction.editReply({
Expand Down
10 changes: 5 additions & 5 deletions src/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const command: Command = {
const sortedCommands = properties.commands.sort((a: Command, b: Command) =>
a.data.name.localeCompare(b.data.name)
)
const helpEmbed = new Discord.MessageEmbed()
const helpEmbed = new Discord.EmbedBuilder()
.setTitle('Help')
.setColor('#B1F7AA')
.setAuthor({
Expand All @@ -23,10 +23,10 @@ export const command: Command = {
})

sortedCommands.forEach((command: Command) => {
helpEmbed.addField(
`/${command.data.name} ${command.args}`,
`${command.data.description}`
)
helpEmbed.addFields({
name: `/${command.data.name} ${command.args}`,
value: `${command.data.description}`
})
})

await interaction.reply({ embeds: [helpEmbed] })
Expand Down
4 changes: 2 additions & 2 deletions src/commands/listteams.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Command } from '../types/command.js'
import { SlashCommandBuilder } from '@discordjs/builders'
import { type Guild, type MessageEmbed, type Role, type User, type Collection, type CommandInteraction, type GuildMember } from 'discord.js'
import { type Guild, type EmbedBuilder, type Role, type User, type Collection, type CommandInteraction, type GuildMember } from 'discord.js'
import { type Properties } from '../types/properties.js'
import { createEmbed } from '../modules/functions.js'
import path from 'path'
Expand Down Expand Up @@ -44,7 +44,7 @@ export const command: Command = {
}
}

function createTeamEmbeds (lobbyVcMembers: Collection<string, GuildMember>, firstTeamRoleId: any, secondTeamRoleId: any, spectatorRoleId: any, guild: Guild, firstTeamVcId: any, secondTeamVcId: any, lobbyVcId: any): MessageEmbed[] {
function createTeamEmbeds (lobbyVcMembers: Collection<string, GuildMember>, firstTeamRoleId: any, secondTeamRoleId: any, spectatorRoleId: any, guild: Guild, firstTeamVcId: any, secondTeamVcId: any, lobbyVcId: any): EmbedBuilder[] {
const firstTeam: User[] = lobbyVcMembers
.filter((member: GuildMember) => member.roles.cache.some((role: Role) => role.id === firstTeamRoleId))
.map((guildmember: GuildMember) => guildmember.user)
Expand Down
2 changes: 1 addition & 1 deletion src/events/ratelimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const event: PlootEvent = {
name: 'rateLimit',
async execute (rateLimitData: RateLimitData) {
logger.info(
`Rate limit reached! Timeout: ${rateLimitData.timeout} Limit: ${rateLimitData.limit}`
`Rate limit reached! Timeout: ${rateLimitData.timeToReset} Limit: ${rateLimitData.limit}`
)
}
}
4 changes: 2 additions & 2 deletions src/events/ready.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Client } from 'discord.js'
import { ActivityType, type Client } from 'discord.js'
import { type Properties } from '../types/properties.js'
import fs from 'fs'
import path, { dirname } from 'path'
Expand Down Expand Up @@ -64,6 +64,6 @@ export const event: PlootEvent = {
logger.info(
`${client.user!.tag}, ready to serve ${client.users.cache.size} users in ${client.guilds.cache.size} servers.`
)
client.user!.setActivity(' everyone 👀', { type: 'WATCHING' })
client.user!.setActivity(' everyone 👀', { type: ActivityType.Watching })
}
}
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, Intents, Collection } from 'discord.js'
import { Client, GatewayIntentBits, Collection } from 'discord.js'
import fs from 'fs'
import path, { dirname } from 'path'
import { logging } from './logging/winston.js'
Expand All @@ -13,9 +13,9 @@ const __dirname = dirname(fileURLToPath(new URL('.', import.meta.url)))
const logger = logging(path.basename(__filename))
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_VOICE_STATES,
Intents.FLAGS.GUILD_MEMBERS
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers
]
})

Expand Down
4 changes: 2 additions & 2 deletions src/modules/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export function chunk (arr: User[], chunkSize: number): User[][] {
return R
}

export function createEmbed (list: User[], title: string, color: HexColorString, guild: Guild): Discord.MessageEmbed {
const embed = new Discord.MessageEmbed()
export function createEmbed (list: User[], title: string, color: HexColorString, guild: Guild): Discord.EmbedBuilder {
const embed = new Discord.EmbedBuilder()
.setTitle(title)
.setColor(color)
.setAuthor({
Expand Down
Loading