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

v5.13 #1063

Merged
merged 12 commits into from
Nov 20, 2023
2 changes: 1 addition & 1 deletion commands.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bastion",
"version": "10.12.1",
"version": "10.13.0",
"description": "Get an enhanced Discord experience!",
"type": "module",
"homepage": "https://bastion.traction.one",
Expand All @@ -18,38 +18,38 @@
"test": "eslint src --ext .ts"
},
"devDependencies": {
"@types/discord-rpc": "^4.0.5",
"@types/express": "^4.17.17",
"@types/http-errors": "^2.0.1",
"@types/jsdom": "^21.1.1",
"@types/node": "^20.5.1",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"eslint": "^8.47.0",
"typescript": "^5.1.6"
"@types/discord-rpc": "^4.0.8",
"@types/express": "^4.17.21",
"@types/gamedig": "^4.0.5",
"@types/http-errors": "^2.0.4",
"@types/jsdom": "^21.1.5",
"@types/node": "^20.9.2",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint": "^8.54.0",
"typescript": "^5.2.2"
},
"dependencies": {
"@bastion/tesseract": "^5.0.4",
"@bastion/tesseract": "^5.1.0",
"@discordjs/opus": "^0.9.0",
"@iamtraction/google-translate": "^2.0.1",
"@types/gamedig": "^4.0.1",
"discord-rpc": "^4.0.1",
"dotenv": "^16.3.1",
"emoji-regex": "^10.2.1",
"gamedig": "^4.0.7",
"emoji-regex": "^10.3.0",
"gamedig": "^4.1.0",
"jsdom": "^22.1.0",
"libsodium-wrappers": "^0.7.11",
"mathjs": "^11.9.1",
"play-dl": "^1.9.6",
"libsodium-wrappers": "^0.7.13",
"mathjs": "^12.1.0",
"play-dl": "^1.9.7",
"r6api.js": "^4.4.1",
"undici": "^5.23.0",
"undici": "^5.27.2",
"ytdl-core": "^4.11.5",
"ytpl": "^2.3.0"
},
"optionalDependencies": {
"bufferutil": "^4.0.7",
"bufferutil": "^4.0.8",
"erlpack": "github:discord/erlpack",
"utf-8-validate": "^6.0.3",
"zlib-sync": "^0.1.8"
"zlib-sync": "^0.1.9"
}
}
3 changes: 2 additions & 1 deletion src/commands/config/liveStreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Command } from "@bastion/tesseract";
import GuildModel from "../../models/Guild.js";
import { isPublicBastion } from "../../utils/constants.js";
import { checkFeature, Feature, getPremiumTier } from "../../utils/premium.js";
import { TWITCH_CHANNEL } from "../../utils/regex.js";

class LiveStreamsCommand extends Command {
constructor() {
Expand Down Expand Up @@ -47,7 +48,7 @@ class LiveStreamsCommand extends Command {
if (twitchChannel || channel || message) {
// update followed channels
if (twitchChannel) {
guildDocument.twitchNotificationUsers = guildDocument.twitchNotificationUsers?.includes(twitchChannel) ? guildDocument.twitchNotificationUsers.filter(u => u !== twitchChannel) : guildDocument.twitchNotificationUsers?.concat(twitchChannel);
guildDocument.twitchNotificationUsers = guildDocument.twitchNotificationUsers?.includes(twitchChannel) ? guildDocument.twitchNotificationUsers.filter(u => TWITCH_CHANNEL.test(u)).filter(u => u !== twitchChannel) : guildDocument.twitchNotificationUsers?.concat(twitchChannel);

// check for limits
if (isPublicBastion(interaction.client.user.id)) {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/music/shuffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class ShuffleCommand extends Command {
public async exec(interaction: ChatInputCommandInteraction<"cached">): Promise<unknown> {
const studio = (interaction.client as Client).studio.get(interaction.guild);

// shuffle the music queue
arrays.shuffle(studio.queue);

if (studio?.queue?.length) {
// shuffle the music queue
arrays.shuffle(studio.queue);

return await interaction.reply({ content: (interaction.client as Client).locales.getText(interaction.guildLocale, "musicQueueShuffle") });
}

Expand Down
46 changes: 36 additions & 10 deletions src/commands/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,54 @@ class PollCommand extends Command {
{
type: ApplicationCommandOptionType.String,
name: "option1",
description: "The first option for the poll's answer.",
description: "The 1st option for the poll's answer.",
required: true,
},
{
type: ApplicationCommandOptionType.String,
name: "option2",
description: "The first option for the poll's answer.",
description: "The 2nd option for the poll's answer.",
required: true,
},
{
type: ApplicationCommandOptionType.String,
name: "option3",
description: "The first option for the poll's answer.",
description: "The 3rd option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.String,
name: "option4",
description: "The first option for the poll's answer.",
description: "The 4th option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.String,
name: "option5",
description: "The 5th option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.String,
name: "option6",
description: "The 6th option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.String,
name: "option7",
description: "The 7th option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.String,
name: "option8",
description: "The 8th option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.String,
name: "option9",
description: "The 9th option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.String,
name: "option10",
description: "The 10th option for the poll's answer.",
},
{
type: ApplicationCommandOptionType.Integer,
Expand All @@ -63,12 +93,8 @@ class PollCommand extends Command {

public async exec(interaction: ChatInputCommandInteraction<"cached">): Promise<unknown> {
const question = interaction.options.getString("question");
const options = [
interaction.options.getString("option1"),
interaction.options.getString("option2"),
interaction.options.getString("option3"),
interaction.options.getString("option4"),
].filter(o => !!o?.trim());

const options = Array.from(Array(10)).map((_, i) => interaction.options.getString("option" + (i + 1))).filter(o => !!o?.trim());
const timer = interaction.options.getInteger("timer");

// check for limits
Expand Down
6 changes: 5 additions & 1 deletion src/schedulers/liveStreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ class LiveStreamNotificationScheduler extends Scheduler {
// twitch streams
if (guild.twitchNotificationChannel && this.client.guilds.cache.get(guild.id).channels.cache.has(guild.twitchNotificationChannel) && guild.twitchNotificationUsers?.length) {
// get current live streams
const { body } = await requests.get("https://api.twitch.tv/helix/streams/?user_login=" + guild.twitchNotificationUsers.join("&user_login="), {
const { body, statusCode } = await requests.get("https://api.twitch.tv/helix/streams/?user_login=" + guild.twitchNotificationUsers.join("&user_login="), {
"authorization": "Bearer " + (this.client.settings as Settings).get("twitch").accessToken,
"client-id": (this.client.settings as Settings).get("twitch").clientId,
});

if (statusCode >= 400) {
Logger.error(await body.json());
}

const streams: TwitchStream[] = (await body.json())?.["data"] || [];

// streams that were already notified
Expand Down
2 changes: 2 additions & 0 deletions src/utils/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ export const WEBHOOK_URL = /(?:https:\/\/)(?:www\.)?(?:discordapp|discord)\.com\
export const REGEX_CMYK = /^(\d{1,2}|100) (\d{1,2}|100) (\d{1,2}|100) (\d{1,2}|100)$/;
export const REGEX_RGB = /^(\d{1,2}|1\d{2}|2[0-5]{2}) (\d{1,2}|1\d{2}|2[0-5]{2}) (\d{1,2}|1\d{2}|2[0-5]{2})$/;
export const REGEX_HEX = /^#?(?:(?:([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2}))|(?:([0-9A-F])([0-9A-F])([0-9A-F])))$/i;

export const TWITCH_CHANNEL = /^[a-z\d][\w]{0,24}$/i;
Loading