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

Added a embed style for all command. #35

Closed
wants to merge 0 commits into from
Closed

Added a embed style for all command. #35

wants to merge 0 commits into from

Conversation

BadEnd777
Copy link

Description

Added a embed style for the report command.

Changes

  • Deleted
await channel.send(
  [
    `Reported message: https://discord.com/channels/${interaction.guild.id}/${interaction.channelId}/${interaction.targetId} (reported ${messageReportCount} times)`,
    `Message author: ${member.user} (reported ${reporteeCount} times)`,
    `Reported by: ${interaction.user} (sent ${reporterCount} reports)`,
  ].join('\n'),
)
  • Added
const messagelink = `https://discord.com/channels/${interaction.guild.id}/${interaction.channelId}/${interaction.targetId}`

// TODO: Add a button to delete the message and ban the user (Mod only)
const embed = {
  title: 'Reported message',
  url: messagelink,
  color: 0xff0000,
  thumbnail: {
    url: member.user.displayAvatarURL(),
  },
  fields: [
    { name: 'Message author', value: member.toString(), inline: true },
    { name: 'Reported by', value: interaction.user.toString(), inline: true },
    {
      name: 'Reported message',
      value: `\`\`\`${message.content}\`\`\`\n[Jump to message](${messagelink})`,
    },
  ],
  timestamp: new Date(),
}

await channel.send({ embeds: [Object.assign(embed)] })

@buskun
Copy link
Collaborator

buskun commented May 18, 2023

Can we separate the embed template creation to another function accepting required information?

const getMessageReportingEmbed = (...) => ({ /* Embed object here */ })

@BadEnd777
Copy link
Author

BadEnd777 commented May 18, 2023

yap, it can be done
but normally, we create a new embed for each command because the data we need is not the same
but there are some that can be used as a template, such as
image command that will only have an image and description

Ex: template of image command

cosnt ImageEmbed = (url: string, description: string) => ({
  description,
  image: { url },
})

Ex: usage

await channel.send({
  embeds: [ImageEmbed("https://i.imgur.com/...", "This is a cat")],
});

but actually the discord.js lib already has EmbedBuilder to use, but I didn't use it because I think it's not cool XD.

@dtinth
Copy link
Collaborator

dtinth commented May 18, 2023

please add some screenshot so we see the end result krubb 🙏

beam41 added a commit to beam41/kaogeek-discord-bot that referenced this pull request May 18, 2023
dtinth pushed a commit that referenced this pull request May 18, 2023
* Beautify bot reply using embed

* revert report embed for #35
@dtinth
Copy link
Collaborator

dtinth commented May 18, 2023

meanwhile, i just merged #37 because the implementation is simple and PR is very small scope and the PR author also provided a screenshot. but there are other valid improvements in this PR, please rebase krub 🙏

@buskun
Copy link
Collaborator

buskun commented May 18, 2023

yap, it can be done but normally, we create a new embed for each command because the data we need is not the same but there are some that can be used as a template, such as image command that will only have an image and description

Ex: template of image command

cosnt ImageEmbed = (url: string, description: string) => ({
  description,
  image: { url },
})

Ex: usage

await channel.send({
  embeds: [ImageEmbed("https://i.imgur.com/...", "This is a cat")],
});

but actually the discord.js lib already has EmbedBuilder to use, but I didn't use it because I think it's not cool XD.

My purpose is not for reusability for this matter, it is more toward readability and testing (in the future).
Also, I am fine with both builder and raw one, but if we are using raw js object one, please also specify type for the embed variable.

README.md Outdated
cp .env.example .env

# Change node version to 16
nvm install v16 # if you don't have node 16 installed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project actually use node 18, you might want to change this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in package.json, it specifies both v16 and v18.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yap v16 and v18, but i'm use v19 is default.
I and someone must change node version to develop.

Thank you

Copy link
Collaborator

@leomotors leomotors May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to nvm use. It will auto detect the version in .nvmrc

@BadEnd777
Copy link
Author

please add some screenshot so we see the end result krubb 🙏

image

@BadEnd777
Copy link
Author

yap, it can be done but normally, we create a new embed for each command because the data we need is not the same but there are some that can be used as a template, such as image command that will only have an image and description
Ex: template of image command

cosnt ImageEmbed = (url: string, description: string) => ({
  description,
  image: { url },
})

Ex: usage

await channel.send({
  embeds: [ImageEmbed("https://i.imgur.com/...", "This is a cat")],
});

but actually the discord.js lib already has EmbedBuilder to use, but I didn't use it because I think it's not cool XD.

My purpose is not for reusability for this matter, it is more toward readability and testing (in the future). Also, I am fine with both builder and raw one, but if we are using raw js object one, please also specify type for the embed variable.

I will try. Thank you.

src/client.ts Outdated
)
const commandFolders = globSync(
path.resolve(this.__dirname, 'commands/**/*.{js,ts}'),
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This revert #33 please change back

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back then.

Copy link
Collaborator

@leomotors leomotors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run pnpm format

@BadEnd777
Copy link
Author

Please run pnpm format

all done. maybe.

@BadEnd777 BadEnd777 changed the title Added a embed style for the report command. Added a embed style for all command. May 18, 2023
@BadEnd777 BadEnd777 closed this May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants