-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,453 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js') | ||
|
||
module.exports = { | ||
permissions: [ | ||
PermissionFlagsBits.SendMessages, | ||
PermissionFlagsBits.AttachFiles, | ||
], | ||
data: new SlashCommandBuilder() | ||
.setName('attachment') | ||
.setDescription('Upload the file and send it in the chat.') | ||
.setDescriptionLocalizations({ | ||
th: 'อัปโหลดไฟล์แล้วส่งไปในแชท', | ||
}) | ||
.setDefaultMemberPermissions(PermissionFlagsBits.AttachFiles) | ||
.setDMPermission(true) | ||
.addAttachmentOption((option) => | ||
option | ||
.setName('attachment') | ||
.setDescription('Things to be attached to the message to be sent.') | ||
.setDescriptionLocalizations({ | ||
th: 'สิ่งที่ต้องการแนบไปด้วยข้อความที่จะส่ง', | ||
}) | ||
.setRequired(true) | ||
) | ||
.addChannelOption((option) => | ||
option | ||
.setName('channel') | ||
.setDescription('The channel to send the attachment to') | ||
.setDescriptionLocalizations({ | ||
th: 'ช่องที่จะส่งไฟล์', | ||
}) | ||
.setRequired(false) | ||
), | ||
async execute(interaction) { | ||
const inputAttachment = interaction.options.getAttachment('attachment') | ||
const inputChannel = interaction.options.getChannel('channel') ?? null | ||
|
||
if (!inputChannel) { | ||
await interaction.channel.send({ | ||
files: [inputAttachment], | ||
}) | ||
} else { | ||
await inputChannel.send({ | ||
files: [inputAttachment], | ||
}) | ||
} | ||
|
||
await interaction.reply({ | ||
content: inputChannel | ||
? interaction.client.i18n.t('commands.attachment.sended_to_channel') | ||
: interaction.client.i18n.t('commands.attachment.sended', { | ||
id: inputChannel.id, | ||
}), | ||
ephemeral: true, | ||
}) | ||
}, | ||
} |
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,76 @@ | ||
const { | ||
SlashCommandBuilder, | ||
ChannelType, | ||
PermissionFlagsBits, | ||
} = require('discord.js') | ||
const { catchError } = require('../../utils/consoleUtils') | ||
|
||
module.exports = { | ||
permissions: [ | ||
PermissionFlagsBits.SendMessages, | ||
PermissionFlagsBits.ManageMessages, | ||
], | ||
data: new SlashCommandBuilder() | ||
.setName('crosspost') | ||
.setDescription( | ||
'Publishes a message in an announcement channel to all channels following it.' | ||
) | ||
.setDescriptionLocalizations({ | ||
th: 'เผยแพร่ข้อความในช่องประกาศไปยังทุกช่องที่ติดตาม', | ||
}) | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages) | ||
.setDMPermission(true) | ||
.addStringOption((option) => | ||
option | ||
.setName('id') | ||
.setDescription('ID of message to be published') | ||
.setDescriptionLocalizations({ | ||
th: 'ไอดีของข้อความที่ต้องการเผยแพร่', | ||
}) | ||
.setRequired(true) | ||
), | ||
async execute(interaction) { | ||
const inputID = interaction.options.getString('id') | ||
|
||
if (interaction.channel.type !== ChannelType.GuildAnnouncement) | ||
return await interaction.reply({ | ||
content: interaction.client.i18n.t( | ||
'commands.crosspost.is_not_valid_type' | ||
), | ||
ephemeral: true, | ||
}) | ||
|
||
try { | ||
const message = await interaction.channel.messages.fetch(inputID) | ||
|
||
if (!message) | ||
return await interaction.reply({ | ||
content: interaction.client.i18n.t( | ||
'commands.crosspost.message_not_found' | ||
), | ||
ephemeral: true, | ||
}) | ||
if (!message.crosspostable) | ||
return await interaction.reply({ | ||
content: interaction.client.i18n.t( | ||
'commands.crosspost.can_not_published' | ||
), | ||
ephemeral: true, | ||
}) | ||
|
||
await message.crosspost() | ||
} catch (error) { | ||
catchError( | ||
interaction.client, | ||
interaction, | ||
module.exports.data.name, | ||
error | ||
) | ||
} | ||
|
||
await interaction.reply({ | ||
content: interaction.client.i18n.t('commands.crosspost.published'), | ||
ephemeral: true, | ||
}) | ||
}, | ||
} |
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,60 @@ | ||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js') | ||
const { catchError } = require('../../utils/consoleUtils') | ||
|
||
module.exports = { | ||
permissions: [ | ||
PermissionFlagsBits.SendMessages, | ||
PermissionFlagsBits.ManageMessages, | ||
], | ||
data: new SlashCommandBuilder() | ||
.setName('delete') | ||
.setDescription('Delete unwanted messages') | ||
.setDescriptionLocalizations({ | ||
th: 'ลบข้อความที่ไม่ต้องการ', | ||
}) | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages) | ||
.setDMPermission(true) | ||
.addStringOption((option) => | ||
option | ||
.setName('id') | ||
.setDescription('ID of the message you want to delete') | ||
.setDescriptionLocalizations({ | ||
th: 'ไอดีของข้อความที่ต้องการลบ', | ||
}) | ||
.setRequired(true) | ||
), | ||
async execute(interaction) { | ||
const inputID = interaction.options.getString('id') | ||
|
||
try { | ||
const message = await interaction.channel.messages.fetch(inputID) | ||
|
||
if (!message) | ||
return await interaction.reply({ | ||
content: interaction.client.i18n.t( | ||
'commands.delete.message_not_found' | ||
), | ||
ephemeral: true, | ||
}) | ||
if (!message.deleteable) | ||
return await interaction.reply({ | ||
content: interaction.client.i18n.t('commands.delete.can_not_delete'), | ||
ephemeral: true, | ||
}) | ||
|
||
await message.delete() | ||
} catch (error) { | ||
catchError( | ||
interaction.client, | ||
interaction, | ||
module.exports.data.name, | ||
error | ||
) | ||
} | ||
|
||
await interaction.reply({ | ||
content: interaction.client.i18n.t('commands.delete.deleted'), | ||
ephemeral: true, | ||
}) | ||
}, | ||
} |
Oops, something went wrong.