Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
chore(release): version 3.1.0 (#949)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: mzrtamp <[email protected]>
  • Loading branch information
3 people authored Oct 29, 2022
1 parent 87e09c6 commit 8057291
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 178 deletions.
26 changes: 24 additions & 2 deletions .replit
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
language="nodejs"
run="npm start"
run = "npm run start"

[languages.typescript]
pattern = "**/{*.ts,*.js,*.tsx,*.jsx}"
syntax = "typescript"

[languages.typescript.languageServer]
start = [ "typescript-language-server", "--stdio" ]

[packager]
language = "nodejs"

[packager.features]
packageSearch = true
guessImports = true

[env]
XDG_CONFIG_HOME = "/home/runner/.config"

[nix]
channel = "stable-21_11"

[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config"]
1 change: 1 addition & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
Expand Down
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ $ npm start

## Hosting Setup

### Heroku
You can host this bot to make it stay online on Heroku.

<a href="https://heroku.com/deploy?template=https://github.com/Clytage/rawon"><img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy to Heroku"></a>
<a href="http://www.youtube.com/watch?feature=player_embedded&v=9csIDZYpaJM" target="_blank">
<img src="http://img.youtube.com/vi/9csIDZYpaJM/0.jpg" alt="Setup Guide Video" width="360" border="10" />
</a>

### Glitch
You can use Glitch too for this project, featured with its code editor.
Expand All @@ -46,7 +45,7 @@ You can use Glitch too for this project, featured with its code editor.
2. Go to [glitch.com](https://glitch.com) and make an account
3. Click **New Project** then **Import from GitHub**, specify the pop-up field with `https://github.com/<your-name>/rawon` (without `<>`)
4. Please wait for a while, this process takes some minutes
5. Find `.env` file and delete it, find `.env_example` file and rename it back to `.env`
5. Find `.env` file and delete it, then find `.env_example` file and rename it to `.env`
6. After specifying `.env`, open **Tools** > **Terminal**
7. Type `refresh`, and track the process from **Logs**

Expand Down
88 changes: 0 additions & 88 deletions app.json

This file was deleted.

94 changes: 40 additions & 54 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,46 @@
import { downloadExecutable } from "./yt-dlp-utils";
import { existsSync, readFileSync, writeFileSync, rmSync } from "fs";
import { execSync } from "child_process";
import { existsSync, rmSync } from "fs";
import { resolve } from "path";
import { Server } from "https";
import module from "module";

const isGlitch = (
process.env.PROJECT_DOMAIN !== undefined &&
process.env.PROJECT_INVITE_TOKEN !== undefined &&
process.env.API_SERVER_EXTERNAL !== undefined &&
process.env.PROJECT_REMIX_CHAIN !== undefined);
const ensureEnv = arr => arr.every(x => process.env[x] !== undefined);

const isReplit = (
process.env.REPLIT_DB_URL !== undefined &&
process.env.REPL_ID !== undefined &&
process.env.REPL_IMAGE !== undefined &&
process.env.REPL_LANGUAGE !== undefined &&
process.env.REPL_OWNER !== undefined &&
process.env.REPL_PUBKEYS !== undefined &&
process.env.REPL_SLUG !== undefined)
const isGlitch = ensureEnv([
"PROJECT_DOMAIN",
"PROJECT_INVITE_TOKEN",
"API_SERVER_EXTERNAL",
"PROJECT_REMIX_CHAIN"
]);

const isGitHub = (
process.env.GITHUB_ENV !== undefined &&
process.env.GITHUB_EVENT_PATH !== undefined &&
process.env.GITHUB_REPOSITORY_OWNER !== undefined &&
process.env.GITHUB_RETENTION_DAYS !== undefined &&
process.env.GITHUB_HEAD_REF !== undefined &&
process.env.GITHUB_GRAPHQL_URL !== undefined &&
process.env.GITHUB_API_URL !== undefined &&
process.env.GITHUB_WORKFLOW !== undefined &&
process.env.GITHUB_RUN_ID !== undefined &&
process.env.GITHUB_BASE_REF !== undefined &&
process.env.GITHUB_ACTION_REPOSITORY !== undefined &&
process.env.GITHUB_ACTION !== undefined &&
process.env.GITHUB_RUN_NUMBER !== undefined &&
process.env.GITHUB_REPOSITORY !== undefined &&
process.env.GITHUB_ACTION_REF !== undefined &&
process.env.GITHUB_ACTIONS !== undefined &&
process.env.GITHUB_WORKSPACE !== undefined &&
process.env.GITHUB_JOB !== undefined &&
process.env.GITHUB_SHA !== undefined &&
process.env.GITHUB_RUN_ATTEMPT !== undefined &&
process.env.GITHUB_REF !== undefined &&
process.env.GITHUB_ACTOR !== undefined &&
process.env.GITHUB_PATH !== undefined &&
process.env.GITHUB_EVENT_NAME !== undefined &&
process.env.GITHUB_SERVER_URL !== undefined
)
const isReplit = ensureEnv([
"REPLIT_DB_URL",
"REPL_ID",
"REPL_IMAGE",
"REPL_LANGUAGE",
"REPL_OWNER",
"REPL_PUBKEYS",
"REPL_SLUG"
]);

const isGitHub = ensureEnv([
"GITHUB_ENV",
"GITHUB_REPOSITORY_OWNER",
"GITHUB_HEAD_REF",
"GITHUB_API_URL",
"GITHUB_REPOSITORY",
"GITHUB_SERVER_URL"
]);

function npmInstall(deleteDir = false, forceInstall = false, additionalArgs = []) {
if (deleteDir) {
const modulesPath = resolve(process.cwd(), "node_modules");

if (existsSync(modulesPath)) {
rmSync(modulesPath, {
recursive: true
recursive: true,
force: true
});
}
}
Expand All @@ -63,6 +49,17 @@ function npmInstall(deleteDir = false, forceInstall = false, additionalArgs = []
}

if (isGlitch) {
const gitIgnorePath = resolve(process.cwd(), ".gitignore");
try {
const data = readFileSync(gitIgnorePath, "utf8").toString();
if (data.includes("dev.env")) {
writeFileSync(gitIgnorePath, data.replace("\ndev.env", ""));
console.info("Removed dev.env from .gitignore");
}
} catch {
console.error("Failed to remove dev.env from .gitignore");
}

try {
console.info("[INFO] Trying to re-install modules...");
npmInstall();
Expand All @@ -84,24 +81,13 @@ if (isGlitch) {
}
}

if (isReplit) {
console.warn("[WARN] We haven't added stable support for running this bot using Replit, bugs and errors may come up.");

if (Number(process.versions.node.split(".")[0]) < 16) {
console.info("[INFO] This Replit doesn't use Node.js v16 or newer, trying to install Node.js v16...");
execSync(`npm i --save-dev [email protected] && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH`);
console.info("[INFO] Node.js v16 has been installed, please restart the bot.");
process.exit(0);
}
}

if (isGitHub) {
console.warn("[WARN] Running this bot using GitHub is not recommended.");
}

const require = module.createRequire(import.meta.url);

if (!isGlitch) {
if (!isGlitch && !isReplit) {
try {
require("ffmpeg-static");
} catch {
Expand Down
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rawon",
"version": "3.0.0",
"version": "3.1.0",
"description": "A simple powerful Discord music bot built to fulfill your production desires. Easy to use, with no coding required.",
"main": "index.js",
"type": "module",
Expand Down
12 changes: 12 additions & 0 deletions replit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs }: {
deps = [
pkgs.python38
pkgs.ffmpeg.bin
pkgs.yarn
pkgs.esbuild
pkgs.nodejs-16_x

pkgs.nodePackages.typescript
pkgs.nodePackages.typescript-language-server
];
}
4 changes: 3 additions & 1 deletion src/commands/moderation/ModLogsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export class ModLogsCommand extends BaseCommand {
ctx.reply({
embeds: [
createEmbed("info")
.setAuthor(i18n.__("commands.moderation.modlogs.embedTitle"))
.setAuthor({
name: i18n.__("commands.moderation.modlogs.embedTitle")
})
.addField(
`${this.client.config.mainPrefix}modlogs enable`,
i18n.__("commands.moderation.modlogs.slashEnableDescription")
Expand Down
4 changes: 3 additions & 1 deletion src/commands/music/DJCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export class DJCommand extends BaseCommand {
ctx.reply({
embeds: [
createEmbed("info")
.setAuthor(i18n.__("commands.music.dj.embedTitle"))
.setAuthor({
name: i18n.__("commands.music.dj.embedTitle")
})
.addField(
`${this.client.config.mainPrefix}dj enable`,
i18n.__("commands.music.dj.slashEnableDescription")
Expand Down
Loading

0 comments on commit 8057291

Please sign in to comment.