Skip to content

🚀 release: v0.1.20 alpha #8

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

Merged
merged 15 commits into from
Apr 1, 2025
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
10 changes: 10 additions & 0 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Support this open-source project.
# Maintained by Waren Gonzaga under WG Technology Labs with contributions from the community.
# GitHub Sponsors: https://github.com/sponsors/wgtechlabs
# Buy Me a Coffee: https://buymeacoffee.com/wgtechlabs

github: [wgtechlabs, warengonzaga]
buy_me_a_coffee: [wgtechlabs, warengonzaga]

# Your support directly funds continued development, maintenance, and new features.
# Every contribution helps ensure this project remains free, up-to-date, and accessible to all.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unthread Discord Bot 🤖

[![made by](https://img.shields.io/badge/made%20by-WG%20Technology%20Labs-0060a0.svg?logo=github&longCache=true&labelColor=181717&style=flat-square)](https://github.com/wgtechlabs) [![sponsors](https://img.shields.io/badge/sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=white&labelColor=181717&style=flat-square)](https://github.com/sponsors/warengonzaga)
[![made by](https://img.shields.io/badge/made%20by-WG%20Technology%20Labs-0060a0.svg?logo=github&longCache=true&labelColor=181717&style=flat-square)](https://github.com/wgtechlabs) [![sponsors](https://img.shields.io/badge/sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=white&labelColor=181717&style=flat-square)](https://github.com/sponsors/wgtechlabs)

<!-- [![release](https://img.shields.io/github/release/wgtechlabs/unthread-discord-bot.svg?logo=github&labelColor=181717&color=green&style=flat-square)](https://github.com/wgtechlabs/unthread-discord-bot/releases) [![star](https://img.shields.io/github/stars/wgtechlabs/unthread-discord-bot.svg?&logo=github&labelColor=181717&color=yellow&style=flat-square)](https://github.com/wgtechlabs/unthread-discord-bot/stargazers) [![license](https://img.shields.io/github/license/wgtechlabs/unthread-discord-bot.svg?&logo=github&labelColor=181717&style=flat-square)](https://github.com/wgtechlabs/unthread-discord-bot/blob/main/license) -->

Expand Down
128 changes: 128 additions & 0 deletions code_of_conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
sudo@wgtechlabs.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
69 changes: 69 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 🎯 Contribute to Open Source

Any contributions are welcome, encouraged, and valued. See the following information below for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for me as maintainer and smooth out the experience for all involved. The community looks forward to your contributions. 🎉✌✨

## 📋 Code of Conduct

This project and everyone participating in it is governed by the project's [Code of Conduct](./code_of_conduct.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to <sudo@wgtechlabs.com>.

## 💖 How to Contribute

There are many ways to contribute to this open source project. Any contributions are welcome and appreciated. Be sure to read the details of each section for you to start contributing.

### 🧬 Development

If you can write code then create a pull request to this repo and I will review your code. Please consider submitting your pull request to the `dev` branch. I will auto reject if you submit your pull request to the `main` branch.

#### 🔧 Setup

To get started with development:

1. **Fork and clone the repository**
```bash
git clone https://github.com/your-username/unthread-discord-bot.git
cd unthread-discord-bot
```

2. **Install dependencies**
```bash
yarn install
# or
npm install
```

3. **Set up environment variables**
- Copy `.env.example` to `.env`
- Fill in the required information as described in the README

4. **Start the bot in development mode**
```bash
yarn dev
# or
npm run dev
```

5. **Deploy commands when needed**
```bash
yarn deploycommand
# or
npm run deploycommand
```

Please refer to the [README](./README.md) for more detailed setup instructions, including Discord application setup and webhook configuration.

### 📖 Documentation

Improvements to documentation are always welcome! This includes:
- README updates
- Code comments
- Examples and usage guides
- Fixing typos or clarifying existing documentation

### 🐞 Reporting Bugs

For any security bugs or issues, please read the [security policy](./security.md).
For other bugs, please create an issue using the bug report template.

---

💻 with ❤️ by [Waren Gonzaga](https://warengonzaga.com), [WG Technology Labs](https://wgtechlabs.com), and [Him](https://www.youtube.com/watch?v=HHrxS4diLew&t=44s) 🙏
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "unthread-discord-bot",
"description": "A simple discord bot integration for unthread.io",
"version": "0.1.8",
"version": "0.1.20-alpha",
"private": true,
"main": "index.js",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Security

If you identify any security vulnerabilities or concerns within this repository, please report them promptly by emailing us at [security@wgtechlabs.com](mailto:security@wgtechlabs.com).

Your efforts to help us maintain the safety and integrity of our open-source projects are greatly appreciated. Thank you for contributing to a more secure community!

---

🔐 with ❤️ by [Waren Gonzaga](https://warengonzaga.com), [WG Technology Labs](https://wgtechlabs.com) and [Him](https://www.youtube.com/watch?v=HHrxS4diLew&t=44s) 🙏
58 changes: 51 additions & 7 deletions src/commands/utilities/ping.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
const { SlashCommandBuilder } = require('discord.js');
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');

/**
* Ping Command
*
* Provides diagnostic information about the bot's connection to Discord.
* Displays two metrics:
* - API Latency: Measures the time taken for a round-trip interaction with Discord.
* - WebSocket Heartbeat: Indicates the current ping to Discord's gateway.
*
* @module commands/utilities/ping
*/
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
await interaction.reply('Pong!');
},
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Shows bot latency and API ping metrics.'),

/**
* Executes the ping command.
*
* @async
* @param {Interaction} interaction - The interaction object from Discord.js.
* @returns {Promise<void>}
*
* Implementation Details:
* - Uses `deferReply` to measure API latency accurately.
* - Calculates round-trip latency and retrieves WebSocket heartbeat.
* - Sends results in an embedded message for better readability.
*/
async execute(interaction) {
// Defer the reply to calculate API latency accurately.
const sent = await interaction.deferReply({ fetchReply: true });

// Calculate the API latency (round-trip time).
const apiLatency = sent.createdTimestamp - interaction.createdTimestamp;

// Retrieve the WebSocket heartbeat from the client.
const wsHeartbeat = interaction.client.ws.ping;

// Create an embed to display the latency metrics.
const embed = new EmbedBuilder()
.setColor(0xEB1A1A) // Red color for emphasis. #EB1A1A
.setTitle('🏓 Pong!')
.addFields(
{ name: 'API Latency', value: `${apiLatency}ms`, inline: true },
{ name: 'WebSocket Heartbeat', value: `${wsHeartbeat}ms`, inline: true }
)
.setFooter({ text: 'Discord Bot Latency Metrics' })
.setTimestamp();

// Edit the deferred reply to include the embed with metrics.
await interaction.editReply({ embeds: [embed] });
},
};
39 changes: 36 additions & 3 deletions src/commands/utilities/server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
const { SlashCommandBuilder } = require('discord.js');
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');

/**
* Server Command
*
* Provides detailed information about the current Discord server.
* Displays key server metrics including server name, member count, and creation date.
*
* @module commands/utilities/server
*/
module.exports = {
data: new SlashCommandBuilder()
.setName('server')
.setDescription('Provides information about the server.'),

/**
* Executes the server command.
*
* @async
* @param {Interaction} interaction - The interaction object from Discord.js.
* @returns {Promise<void>}
*
* Implementation Details:
* - Retrieves server information from the interaction's guild object
* - Formats the server creation timestamp as a Discord timestamp
* - Creates an embedded message with relevant server information
* - Replies to the interaction with the formatted embed
*/
async execute(interaction) {
// interaction.guild is the object representing the Guild in which the command was run
await interaction.reply(`This server is ${interaction.guild.name} and has ${interaction.guild.memberCount} members.`);
const embed = new EmbedBuilder()
.setColor(0xEB1A1A)
.setTitle('Server Information')
.addFields(
{ name: 'Server Name', value: interaction.guild.name, inline: true },
{ name: 'Total Members', value: `${interaction.guild.memberCount}`, inline: true },
{ name: 'Created At', value: `<t:${Math.floor(interaction.guild.createdTimestamp / 1000)}:F>`, inline: false }
)
.setThumbnail(interaction.guild.iconURL({ dynamic: true }))
.setFooter({ text: `Server ID: ${interaction.guild.id}` })
.setTimestamp();

await interaction.reply({ embeds: [embed] });
},
};
40 changes: 36 additions & 4 deletions src/commands/utilities/user.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
const { SlashCommandBuilder } = require('discord.js');
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');

/**
* User Command
*
* Provides detailed information about the Discord user who triggered the command.
* Displays key user information including username, server join date, and account creation date.
*
* @module commands/utilities/user
*/
module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Provides information about the user.'),

/**
* Executes the user command.
*
* @async
* @param {Interaction} interaction - The interaction object from Discord.js.
* @returns {Promise<void>}
*
* Implementation Details:
* - Retrieves user information from the interaction object
* - Formats timestamps using Discord's timestamp formatting
* - Creates an embedded message with relevant user information
* - Replies to the interaction with the formatted embed
*/
async execute(interaction) {
// interaction.user is the object representing the User who ran the command
// interaction.member is the GuildMember object, which represents the user in the specific guild
await interaction.reply(`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`);
const embed = new EmbedBuilder()
.setColor(0xEB1A1A)
.setTitle('User Information')
.addFields(
{ name: 'Username', value: interaction.user.username, inline: true },
{ name: 'Joined Server', value: `<t:${Math.floor(interaction.member.joinedTimestamp / 1000)}:F>`, inline: true },
{ name: 'Account Created', value: `<t:${Math.floor(interaction.user.createdTimestamp / 1000)}:F>`, inline: false }
)
.setThumbnail(interaction.user.displayAvatarURL({ dynamic: true }))
.setFooter({ text: `User ID: ${interaction.user.id}` })
.setTimestamp();

await interaction.reply({ embeds: [embed] });
},
};
Loading