Skip to content

Commit

Permalink
VERSION 0.1 IS LIVE πŸŽ‰
Browse files Browse the repository at this point in the history
Merged from pull request #29 by the Sokora Team
  • Loading branch information
ThatFrogDev authored Nov 4, 2024
2 parents 3b7e961 + 1fef7e7 commit 18cf54f
Show file tree
Hide file tree
Showing 125 changed files with 3,305 additions and 3,748 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build Sokora

on:
push:
branches:
- dev

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Install packages and build
run: npm install && npx tsc -b ./

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
.env
.env
.DS_Store
data.db
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 2,
"useTabs": false,
"arrowParens": "avoid",
"trailingComma": "none",
"printWidth": 100
}
19 changes: 6 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
# Nebula Contributing Guide
# Sokora Contributing Guide

## Prerequisites
- Basic knowledge of [TypeScript](https://typescriptlang.org/) and [discord.js](https://discord.js.org/).
- [Bun](https://bun.sh) and [MySQL](https://mysql.com/) installed.
- [Bun](https://bun.sh) installed.

## Get started with developing
## Get started with contributing
### Getting the code
- Make a fork of this repository.
- Make a fork of this repository.
- Clone your fork.

### Creating your bot
- Head over to the [Discord Developer Portal](https://discord.com/developers/applications) and make a new application.
- Invite your bot to your server.
- Reset and then copy your bot's token.

### Setting up your database
We use MySQL for the database. You need to set one up to be able to run the bot.

- Create a database file called `json.db`
- It is recommended to create a specific user for Nebula only. See [the docs](https://dev.mysql.com/doc/refman/8.0/en/creating-accounts.html) for more information

### Setting up .env
- Copy the `example.env` file and replace the content with your own credentials inside a file called `.env`.
- Run `bun run setup` and our cli tool will install dependencies and write .env for you

### Running
- Run `bun i` to install all the modules needed by the bot.
- Run `bun start`
- Run `bun start`.

Be sure to open a pull request when you're ready to push your changes. Be descriptive of the changes you've made.

Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<div align="center">
<p>
<img src="static/banner.svg" />
<img src="static/banner.png" />
</p>
<p>
<a href="https://discord.gg/7RdABJhQss"><img src="https://img.shields.io/discord/903852579837059113?color=5865F2&logo=discord&logoColor=white" /></a>
<a href="https://discord.gg/c6C25P4BuY"><img src="https://img.shields.io/discord/903852579837059113?color=5865F2&logo=discord&logoColor=white" /></a>
<a href="https://ptb.discord.com/api/oauth2/authorize?client_id=873918300726394960&permissions=8&scope=bot%20applications.commands"><img src="https://img.shields.io/badge/bot-Invite%20the%20bot%20here!-blue" /></a>
</p>
</div>

# About
Nebula is a multiplatform, multipurpose bot with the ability to add extensions to have additional features.
Sokora is a multiplatform, multipurpose bot with the ability to add extensions to have additional features.

**Please note that Nebula is currently in an alpha preview state and only usable within Discord with limited functionality.**
**Please note that Sokora is currently unstable and is only usable within Discord.**

# Contributing
While we're developing the multiplatform version of the bot, you can still [help us](CONTRIBUTING.MD) if you find any bugs.

Only bug fixes are accepted, **no new features!**
Binary file modified bun.lockb
Binary file not shown.
50 changes: 50 additions & 0 deletions cli/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as fs from "fs";
import { createInterface } from "readline";

const readHiddenInput = async (prompt: string): Promise<string> => {
console.log(prompt);

return new Promise(resolve => {
const rl = createInterface({
input: process.stdin,
output: process.stdout
});

const stdin = process.stdin;
if (stdin.isTTY) stdin.setRawMode(true);

stdin.on("data", data => {
if (data.toString() === "\n" || data.toString() === "\r") {
if (stdin.isTTY) stdin.setRawMode(false);
process.stdout.moveCursor(0, -1);
process.stdout.clearLine(1);
rl.close();
}
});

rl.question("", input => {
resolve(input);
});
});
};

const replaceTokenInEnv = (token: string) => {
try {
const envContent = fs.readFileSync(".env", "utf-8");
const updatedContent = envContent.replace("YOURTOKEN", token);
fs.writeFileSync(".env", updatedContent, "utf-8");
console.log("You're good to go, happy coding!");
} catch (error) {
console.error("Error updating .env file:", error);
}
};

const main = async () => {
fs.copyFileSync("example.env", ".env");
const token = await readHiddenInput(
"Paste your token below: (you can get one from https://discord.com/developers/applications)"
);
replaceTokenInEnv(token);
};

main().catch(console.error);
8 changes: 1 addition & 7 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
TOKEN="YOURTOKEN" # The bot token found in the Discord Developer portal

MYSQL_HOST="localhost" # Name of the host
MYSQL_PORT="1234"
MYSQL_USERNAME="username" # Username USED BY YOUR DATABASE
MYSQL_DATABASE="nebula_stable"
MYSQL_PASSWORD="Password123"
TOKEN="YOURTOKEN"
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
{
"name": "nebula",
"description": "Welcome to Nebula, the multipurpose, multiplatform bot.",
"name": "sokora",
"description": "Welcome to Sokora, a multipurpose Discord bot that lets you manage your servers easily.",
"contributors": [
"The Nebula team",
"The Sokora team",
"The GitHub contributors"
],
"version": "0.1.0",
"main": "./src/index.ts",
"type": "module",
"scripts": {
"setup": "bun i && bun run cli/setup.ts",
"start": "bun ./src/index.ts"
},
"dependencies": {
"discord.js": "^14.14.1",
"discord.js": "^14.16.3",
"ms": "^2.1.3",
"mysql2": "^3.6.3",
"node-vibrant": "^3.2.1-alpha.1",
"quick.db": "^9.1.7",
"sharp": "v0.33.0-alpha.11"
"sharp": "^0.33.5"
},
"devDependencies": {
"bun-types": "0.8.1",
"typescript": "^5.2.2"
},
"trustedDependencies": ["sharp"]
"@types/ms": "^0.7.34",
"bun-types": "^1.1.33",
"typescript": "^5.6.3"
}
}
14 changes: 8 additions & 6 deletions src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import { Client, ActivityType } from "discord.js";
import Commands from "./handlers/commands.js";
import Events from "./handlers/events.js";
import { ActivityType, Client } from "discord.js";
import { Commands } from "./handlers/commands";
import { Events } from "./handlers/events";
import { rescheduleUnbans } from "./utils/unbanScheduler";

const client = new Client({
presence: {
activities: [{ name: "with /settings!", type: ActivityType.Playing }]
activities: [{ name: "your feedback!", type: ActivityType.Listening }]
},
intents: [
"Guilds",
"GuildMembers",
"GuildMessages",
"GuildEmojisAndStickers",
"GuildPresences",
"GuildBans",
"MessageContent"
]
});

client.on("ready", async () => {
new Events(client);
console.log("Starting all commands.");
await new Events(client).loadEvents();
await new Commands(client).registerCommands();
console.log("けーっす!");
rescheduleUnbans(client);
});

client.login(process.env.TOKEN);
78 changes: 78 additions & 0 deletions src/commands/About.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
EmbedBuilder,
SlashCommandBuilder,
type ChatInputCommandInteraction
} from "discord.js";
import { genColor } from "../utils/colorGen";
import { imageColor } from "../utils/imageColor";
import { randomise } from "../utils/randomise";

export default class About {
data: SlashCommandBuilder;
constructor() {
this.data = new SlashCommandBuilder()
.setName("about")
.setDescription("Shows information about Sokora.");
}

async run(interaction: ChatInputCommandInteraction) {
const client = interaction.client;
const user = client.user;
const guilds = client.guilds.cache;
const members = guilds.map(guild => guild.memberCount).reduce((a, b) => a + b);
const shards = client.shard?.count;
const avatar = user.displayAvatarURL();
let emojis = ["πŸ’–", "πŸ’", "πŸ’“", "πŸ’—", "πŸ’˜", "πŸ’Ÿ", "πŸ’•", "πŸ’ž"];
if (Math.round(Math.random() * 100) <= 5) emojis = ["⌨️", "πŸ’»", "πŸ–₯️"];

const embed = new EmbedBuilder()
.setAuthor({ name: "β€’ About Sokora", iconURL: avatar })
.setDescription(
"Sokora is a multipurpose Discord bot that lets you manage your servers easily."
)
.setFields(
{
name: "πŸ“ƒ β€’ General",
value: [
"Version **0.1**, *Kaishi*",
`**${members}** members β€’ **${guilds.size}** guild${guilds.size == 1 ? "" : "s"} ${
!shards ? "" : `β€’ **${shards}** shard${shards == 1 ? "" : "s"}`
}`
].join("\n")
},
{
name: "🌌 β€’ Entities involved",
value: [
"**Founder**: Goos",
"**Translator Lead**: ThatBOI",
"**Developers**: Dimkauzh, Froxcey, Golem64, Koslz, MQuery, Nikkerudon, Spectrum, ThatBOI",
"**Designers**: ArtyH, ZakaHaceCosas, Pjanda",
"**Translators**: Dimkauzh, flojo, Golem64, GraczNet, Nikkerudon, ZakaHaceCosas, SaFire, TrulyBlue",
"**Testers**: Blaze, fishy, Trynera",
"And **YOU**, for using Sokora."
].join("\n")
},
{
name: "πŸ”— β€’ Links",
value:
"[GitHub](https://www.github.com/NebulaTheBot) β€’ [YouTube](https://www.youtube.com/@NebulaTheBot) β€’ [Instagram](https://instagram.com/NebulaTheBot) β€’ [Mastodon](https://mastodon.online/@[email protected]) β€’ [Guilded](https://guilded.gg/Nebula) β€’ [Revolt](https://rvlt.gg/28TS9aXy)"
}
)
.setFooter({ text: `Made with ${randomise(emojis)} by the Sokora team` })
.setThumbnail(avatar)
.setColor(user.hexAccentColor ?? (await imageColor(undefined, avatar)) ?? genColor(270));

const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setLabel("β€’ Donate")
.setURL("https://paypal.me/SokoraTheBot")
.setEmoji("⭐")
.setStyle(ButtonStyle.Link)
);

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

0 comments on commit 18cf54f

Please sign in to comment.