Skip to content

Commit 7f7ebcc

Browse files
Merge pull request #107 from Polytoria/v14-upgrade
V14 upgrade has been completed
2 parents c604d5a + c1a1c6b commit 7f7ebcc

23 files changed

Lines changed: 207 additions & 196 deletions

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polytoria-community-bot",
3-
"version": "2.5.0.2",
3+
"version": "2.6.0",
44
"type": "module",
55
"typings": "./types",
66
"scripts": {
@@ -14,14 +14,15 @@
1414
"axios": "^1.4.0",
1515
"canvas": "^2.11.2",
1616
"chalk": "^5.0.0",
17-
"discord.js": "^13.3.1",
17+
"discord.js": "^14.13.0",
1818
"dom-parser": "^0.1.6",
1919
"dotenv": "^16.3.1",
2020
"esm": "^3.2.25",
2121
"module-alias": "^2.2.2",
2222
"string-progressbar": "^1.0.4",
2323
"text-table": "^0.2.0",
2424
"timestamp-conv": "^3.0.0",
25+
"typescript": "^5.1.6",
2526
"uuid": "^8.3.2"
2627
},
2728
"devDependencies": {
@@ -36,7 +37,6 @@
3637
"eslint-plugin-node": "^11.1.0",
3738
"eslint-plugin-promise": "^5.2.0",
3839
"prettier": "^3.0.0",
39-
"prettier-eslint": "^13.0.0",
40-
"typescript": "^4.5.4"
40+
"prettier-eslint": "^13.0.0"
4141
}
4242
}

src/commands/commands.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { MessageEmbed, Message } from 'discord.js'
1+
import { EmbedBuilder, Message } from 'discord.js'
22

33
export async function commands (message: Message) {
4-
const embed: MessageEmbed = new MessageEmbed()
4+
const embed: EmbedBuilder = new EmbedBuilder()
5+
.setColor(0xFF5454)
6+
.setTitle('This command is currently unavailable.')
7+
.setThumbnail('https://starmanthegamer.com/icon.png')
8+
.addFields(
9+
{ name: 'What happened?', value: 'Polytoria has revamped their entire website, and we rely on APIs to access the information we serve to you. With those APIs currently being unavailable, we cannot serve you the requested command.' },
10+
{ name: 'When will this command return?', value: 'In the future when the API for this command returns.', inline: true }
11+
)
12+
.setFooter({ text: 'Thank you for your patience.', iconURL: 'https://starmanthegamer.com/icon.png' })
513

6-
embed.setThumbnail('https://starmanthegamer.com/icon.png')
7-
embed.setColor('#fe5953')
8-
embed.setTitle('This command is currently unavailable.')
9-
embed.addField('What happened?', 'Polytoria has revamped their entire website, and we rely on APIs to access the information we serve to you. With those APIs currently being unavailable, we cannot serve you the requested command.')
10-
embed.addField('When will this command return?', 'In the future when the API for this command returns.')
1114
await message.channel.send({ embeds: [embed] })
1215
}

src/commands/guild.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Message, MessageEmbed, MessageActionRow, MessageButton, Interaction } from 'discord.js'
1+
import { Message, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, BaseInteraction } from 'discord.js'
22
import axios from 'axios'
33
import { responseHandler } from '../utils/responseHandler.js'
44
import { dateUtils } from '../utils/dateUtils.js'
@@ -21,9 +21,9 @@ export async function guild (message: Message, args: string[]): Promise<Message
2121
return message.channel.send(errResult.displayText)
2222
}
2323

24-
const embed = new MessageEmbed()
24+
const embed = new EmbedBuilder()
2525
.setTitle(data.name + ' ' + (data.isVerified === true ? emojiUtils.checkmark : ''))
26-
.setDescription(data.description)
26+
.setDescription(data.description === '' ? 'No description set.' : data.description)
2727
.setURL('https://polytoria.com/guilds/' + data.id.toString())
2828
.setThumbnail(data.thumbnail)
2929
.setColor(data.color)
@@ -65,39 +65,39 @@ export async function guild (message: Message, args: string[]): Promise<Message
6565
.map((member: any) => `[${member.user.username}](https://polytoria.com/users/${member.user.id})`)
6666
.join('\n')
6767

68-
const memberEmbed = new MessageEmbed()
68+
const memberEmbed = new EmbedBuilder()
6969
.setTitle(data.name + ' - Members ' + (data.isVerified === true ? emojiUtils.checkmark : ''))
7070
.setDescription(memberUsernames)
7171
.setThumbnail(data.thumbnail)
7272
.setColor(data.color)
7373
.setURL('https://polytoria.com/guilds/' + data.id.toString())
7474

75-
const guildButton = new MessageButton()
75+
const guildButton = new ButtonBuilder()
7676
.setLabel('Guild')
77-
.setStyle('PRIMARY')
77+
.setStyle(ButtonStyle.Primary)
7878
.setCustomId('guild_button')
7979

80-
const membersButton = new MessageButton()
80+
const membersButton = new ButtonBuilder()
8181
.setLabel('Members')
82-
.setStyle('PRIMARY')
82+
.setStyle(ButtonStyle.Primary)
8383
.setCustomId('members_button')
8484

85-
const nextButton = new MessageButton()
85+
const nextButton = new ButtonBuilder()
8686
.setLabel('Next')
87-
.setStyle('SUCCESS')
87+
.setStyle(ButtonStyle.Success)
8888
.setCustomId('next_button')
8989

90-
const prevButton = new MessageButton()
90+
const prevButton = new ButtonBuilder()
9191
.setLabel('Previous')
92-
.setStyle('DANGER')
92+
.setStyle(ButtonStyle.Danger)
9393
.setCustomId('prev_button')
9494

95-
const actionRow: MessageActionRow = new MessageActionRow()
95+
const actionRow = new ActionRowBuilder<ButtonBuilder>()
9696
.addComponents(
97-
new MessageButton()
97+
new ButtonBuilder()
9898
.setURL(`https://polytoria.com/guilds/${data.id}`)
9999
.setLabel('View on Polytoria')
100-
.setStyle('LINK')
100+
.setStyle(ButtonStyle.Link)
101101
)
102102
.addComponents(
103103
membersButton
@@ -111,8 +111,8 @@ export async function guild (message: Message, args: string[]): Promise<Message
111111
let memberPage = 1
112112

113113
const collector = reply.createMessageComponentCollector({
114-
componentType: 'BUTTON',
115-
filter: (interaction: Interaction) => (
114+
componentType: ComponentType.Button,
115+
filter: (interaction: BaseInteraction) => (
116116
interaction.isButton() && interaction.user.id === message.author.id
117117
),
118118
time: 60000
@@ -129,13 +129,13 @@ export async function guild (message: Message, args: string[]): Promise<Message
129129
await reply.edit({
130130
embeds: [memberEmbed],
131131
components: [
132-
new MessageActionRow().addComponents(guildButton, prevButton, nextButton)
132+
new ActionRowBuilder<ButtonBuilder>().addComponents(guildButton, prevButton, nextButton)
133133
]
134134
})
135135

136136
const guildButtonCollector = reply.createMessageComponentCollector({
137-
componentType: 'BUTTON',
138-
filter: (btnInteraction: Interaction) => (
137+
componentType: ComponentType.Button,
138+
filter: (btnInteraction: BaseInteraction) => (
139139
btnInteraction.isButton() &&
140140
btnInteraction.customId === 'guild_button' &&
141141
btnInteraction.user.id === message.author.id
@@ -154,8 +154,8 @@ export async function guild (message: Message, args: string[]): Promise<Message
154154
})
155155

156156
const nextButtonCollector = reply.createMessageComponentCollector({
157-
componentType: 'BUTTON',
158-
filter: (btnInteraction: Interaction) => (
157+
componentType: ComponentType.Button,
158+
filter: (btnInteraction: BaseInteraction) => (
159159
btnInteraction.isButton() &&
160160
btnInteraction.customId === 'next_button' &&
161161
btnInteraction.user.id === message.author.id
@@ -178,14 +178,14 @@ export async function guild (message: Message, args: string[]): Promise<Message
178178
await reply.edit({
179179
embeds: [memberEmbed],
180180
components: [
181-
new MessageActionRow().addComponents(guildButton, prevButton, nextButton)
181+
new ActionRowBuilder<ButtonBuilder>().addComponents(guildButton, prevButton, nextButton)
182182
]
183183
})
184184
})
185185

186186
const prevButtonCollector = reply.createMessageComponentCollector({
187-
componentType: 'BUTTON',
188-
filter: (btnInteraction: Interaction) => (
187+
componentType: ComponentType.Button,
188+
filter: (btnInteraction: BaseInteraction) => (
189189
btnInteraction.isButton() &&
190190
btnInteraction.customId === 'prev_button' &&
191191
btnInteraction.user.id === message.author.id
@@ -209,7 +209,7 @@ export async function guild (message: Message, args: string[]): Promise<Message
209209
await reply.edit({
210210
embeds: [memberEmbed],
211211
components: [
212-
new MessageActionRow().addComponents(guildButton, prevButton, nextButton)
212+
new ActionRowBuilder<ButtonBuilder>().addComponents(guildButton, prevButton, nextButton)
213213
]
214214
})
215215
}

src/commands/help.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Message, MessageEmbed, MessageActionRow, MessageButton } from 'discord.js'
1+
import { Message, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'
22
import pages from './helpPages.js'
33
import { v4 } from 'uuid'
44

@@ -11,18 +11,17 @@ export async function help (message: Message, args: string[]) {
1111
return pages[currentPage]
1212
}
1313

14-
const embed = new MessageEmbed({
14+
const originalHelpData: any = await changePage()
15+
const embed = new EmbedBuilder({
1516
title: 'List of available commands',
16-
color: '#ff5454',
17+
color: 0xFF5454,
1718
description: 'Prefix: `p!`',
1819
thumbnail: {
1920
url: 'https://cdn.discordapp.com/icons/587167555068624915/4149b9aea50a0fd41260d71ac743407d.webp?size=128'
2021
}
2122
})
2223

23-
// Fetch Friends
24-
const helpData: any = await changePage()
25-
embed.fields = helpData
24+
embed.addFields(originalHelpData)
2625

2726
// Generate Button ID base on current time
2827
const buttonID: string = v4()
@@ -31,13 +30,13 @@ export async function help (message: Message, args: string[]) {
3130
const rightBtnID: string = 'right' + buttonID
3231

3332
// Create Buttons
34-
const leftBtn: MessageButton = new MessageButton().setCustomId(leftBtnID).setLabel('◀').setStyle('PRIMARY').setDisabled(true)
33+
const leftBtn: ButtonBuilder = new ButtonBuilder().setCustomId(leftBtnID).setLabel('◀').setStyle(ButtonStyle.Primary).setDisabled(true)
3534

36-
const pageNumBtn: MessageButton = new MessageButton().setCustomId(pageNum).setLabel(`Page ${currentPage + 1} of ${pagesCount}`).setStyle('SECONDARY')
35+
const pageNumBtn: ButtonBuilder = new ButtonBuilder().setCustomId(pageNum).setLabel(`Page ${currentPage + 1} of ${pagesCount}`).setStyle(ButtonStyle.Secondary)
3736

38-
const rightBtn: MessageButton = new MessageButton().setCustomId(rightBtnID).setLabel('▶').setStyle('PRIMARY')
37+
const rightBtn: ButtonBuilder = new ButtonBuilder().setCustomId(rightBtnID).setLabel('▶').setStyle(ButtonStyle.Primary)
3938

40-
const row = new MessageActionRow().addComponents(leftBtn).addComponents(pageNumBtn).addComponents(rightBtn)
39+
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(leftBtn, pageNumBtn, rightBtn)
4140

4241
const filter = () => true
4342

@@ -74,15 +73,20 @@ export async function help (message: Message, args: string[]) {
7473
leftBtn.setDisabled(false)
7574
}
7675

76+
if (currentPage === 0) {
77+
embed.data.fields = []
78+
embed.addFields(originalHelpData)
79+
} else {
80+
const helpData: any = changePage()
81+
embed.data.fields = []
82+
embed.addFields(helpData)
83+
}
84+
7785
// Set Page
7886
pageNumBtn.setLabel(`Page ${currentPage + 1} of ${pagesCount.toString()}`)
7987

80-
// Fetch Help page
81-
const helpData: any = changePage()
82-
embed.fields = helpData
83-
8488
// Update Embed and Button
85-
const updatedRow = new MessageActionRow().addComponents(leftBtn).addComponents(pageNumBtn).addComponents(rightBtn)
89+
const updatedRow = new ActionRowBuilder<ButtonBuilder>().addComponents(leftBtn, pageNumBtn, rightBtn)
8690
await msg.edit({ embeds: [embed], components: [updatedRow] })
8791
await i.reply({ content: ' ', ephemeral: true })
8892
})

src/commands/info.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
import { MessageEmbed, Message } from 'discord.js'
1+
import { EmbedBuilder, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'
22

33
export async function info (message: Message) {
4-
const embed: MessageEmbed = new MessageEmbed()
4+
const invite = new ButtonBuilder()
5+
.setLabel('Invite us!')
6+
.setURL('https://discord.com/api/oauth2/authorize?client_id=905979909049028649&permissions=414464724032&scope=bot')
7+
.setStyle(ButtonStyle.Link)
58

6-
embed.setThumbnail('https://starmanthegamer.com/icon.png')
7-
embed.setColor('#fe5953')
8-
embed.setTitle('Polytoria Community Bot')
9-
embed.setURL('https://discord.com/api/oauth2/authorize?client_id=905979909049028649&permissions=414464724032&scope=bot')
10-
embed.addField('Version', `Running version ${process.env.npm_package_version}`)
11-
embed.addField('Invite our Bot', 'Tap the title to invite our bot directly to your server!')
12-
embed.addField('We are open-sourced!', 'https://github.com/Polytoria/Polytoria-Community-Bot')
13-
embed.addField('Rewritten by', 'Shiggy, DevPixels, baggy, and more!')
14-
embed.setFooter('Thanks to all collaborators of the project!')
15-
await message.channel.send({ embeds: [embed] })
9+
const github = new ButtonBuilder()
10+
.setLabel('GitHub')
11+
.setURL('https://github.com/Polytoria/CommunityBot')
12+
.setStyle(ButtonStyle.Link)
13+
14+
const row = new ActionRowBuilder<ButtonBuilder>()
15+
.addComponents(github, invite)
16+
17+
const embed: EmbedBuilder = new EmbedBuilder()
18+
.setColor(0xFF5454)
19+
.setTitle('Polytoria Community Bot')
20+
.setURL('https://discord.com/api/oauth2/authorize?client_id=905979909049028649&permissions=414464724032&scope=bot')
21+
.setThumbnail('https://starmanthegamer.com/icon.png')
22+
.addFields(
23+
{ name: 'Version', value: `Currently running version: ${process.env.npm_package_version}` },
24+
{ name: 'Contributed by:', value: 'baggy, Hu Tao, Shiggy, and many more!', inline: true }
25+
)
26+
.setFooter({ text: 'Thank you for using Polytoria Community Bot!', iconURL: 'https://starmanthegamer.com/icon.png' })
27+
28+
await message.channel.send({ embeds: [embed], components: [row] })
1629
}

src/commands/ping.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/commands/place.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Message, MessageEmbed, MessageActionRow, MessageButton } from 'discord.js'
1+
import { Message, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'
22
import axios from 'axios'
33
import { responseHandler } from '../utils/responseHandler.js'
44
import { dateUtils } from '../utils/dateUtils.js'
@@ -36,16 +36,14 @@ export async function place (message: Message, args: string[]) {
3636
externalDesc += data.description
3737
}
3838

39-
const embed = new MessageEmbed({
39+
const embed = new EmbedBuilder({
4040
title: (data.name + ' ' + (data.isFeatured === true ? emojiUtils.star : '')),
4141
description: externalDesc,
4242
thumbnail: {
4343
url: `${data.thumbnail}`
4444
},
4545
url: `https://polytoria.com/places/${data.id}`,
46-
color: '#ff5454',
47-
image: {
48-
},
46+
color: 0xFF5454,
4947
fields: [
5048
{
5149
name: 'Creator',
@@ -95,13 +93,12 @@ export async function place (message: Message, args: string[]) {
9593
]
9694
})
9795

98-
// Create the action row and button
99-
const actionRow = new MessageActionRow()
96+
const actionRow = new ActionRowBuilder<ButtonBuilder>()
10097
.addComponents(
101-
new MessageButton()
98+
new ButtonBuilder()
10299
.setURL(`https://polytoria.com/places/${data.id}`)
103100
.setLabel('View on Polytoria')
104-
.setStyle('LINK')
101+
.setStyle(ButtonStyle.Link)
105102
)
106103

107104
return message.reply({

src/commands/random/randomGuild.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Message, MessageEmbed, MessageActionRow, MessageButton } from 'discord.js'
1+
import { Message, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'
22
import emojiUtils from '../../utils/emojiUtils.js'
33
import { dateUtils } from '../../utils/dateUtils.js'
44
import { randomUtils } from '../../utils/randomUtils.js'
@@ -27,9 +27,9 @@ export async function randomGuild (message: Message, args: string[]) {
2727
const data = randomData.data
2828
const creator = data.creator
2929

30-
const embed = new MessageEmbed()
30+
const embed = new EmbedBuilder()
3131
.setTitle(data.name + ' ' + (data.isVerified === true ? emojiUtils.checkmark : ''))
32-
.setDescription(data.description)
32+
.setDescription(data.description === '' ? 'No description set.' : data.description)
3333
.setURL('https://polytoria.com/guilds/' + data.id.toString())
3434
.setThumbnail(data.thumbnail)
3535
.setColor(data.color)
@@ -65,13 +65,12 @@ export async function randomGuild (message: Message, args: string[]) {
6565
embed.setImage(data.banner)
6666
}
6767

68-
// Create the action row and button
69-
const actionRow = new MessageActionRow()
68+
const actionRow = new ActionRowBuilder<ButtonBuilder>()
7069
.addComponents(
71-
new MessageButton()
70+
new ButtonBuilder()
7271
.setURL(`https://polytoria.com/guilds/${data.id}`)
7372
.setLabel('View on Polytoria')
74-
.setStyle('LINK')
73+
.setStyle(ButtonStyle.Link)
7574
)
7675

7776
return message.reply({

0 commit comments

Comments
 (0)