Skip to content

Commit

Permalink
✨ tweak: export redis
Browse files Browse the repository at this point in the history
  • Loading branch information
warengonzaga authored May 8, 2024
1 parent 1cf6800 commit b4036dc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
10 changes: 2 additions & 8 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ const fs = require("fs");
const path = require("node:path");
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const { serverTime } = require("./utils/core");
const Redis = require("ioredis");
const { redis } = require("./events/database");

// dot env
require("dotenv").config();

// discord bot environment vars
const {
DISCORD_BOT_TOKEN,
REDIS_SERVER_URL
} = process.env;
const { DISCORD_BOT_TOKEN } = process.env;

// discord bot instents and partials
const client = new Client({
Expand All @@ -23,9 +20,6 @@ const client = new Client({
partials: [Partials.Channel, Partials.Message],
});

// connect to redis
const redis = new Redis(REDIS_SERVER_URL);

/**
* Don't modify or update the code below.
* Keep your changes above ^
Expand Down
2 changes: 2 additions & 0 deletions src/events/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ redis.on("reconnecting", () =>{
redis.on("error", (err) => () => {
console.log(`[${serverTime()}][error]: Redis Error: ${err}`);
});

module.exports = redis;
8 changes: 2 additions & 6 deletions src/events/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ const {
serverTime,
CloseButtonComponent } = require("../utils/core");
const { ContextSDK } = require("@context-labs/sdk");
const Redis = require("ioredis");
const { redis } = require("./database");

const {
REDIS_SERVER_URL
} = process.env;

const redis = new Redis(REDIS_SERVER_URL);
// const redis = new Redis(REDIS_SERVER_URL);
const context = new ContextSDK({});

module.exports = {
Expand Down
6 changes: 2 additions & 4 deletions src/events/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ const {
FeedbackButtonComponent } = require("../utils/core");
const { version } = require("../../package.json");
const config = require("../config.json");
const Redis = require("ioredis");
const { redis } = require("./database");
const { ContextSDK } = require("@context-labs/sdk");

// discord bot env
const {
DISCORD_SUPPORT_ROLE_ID,
ASKAI_CHANNEL,
CONTEXT_ID,
REDIS_SERVER_URL } = process.env;
CONTEXT_ID} = process.env;
const roleIDs = DISCORD_SUPPORT_ROLE_ID.split(",");

const redis = new Redis(REDIS_SERVER_URL);
const context = new ContextSDK({});

module.exports = {
Expand Down

0 comments on commit b4036dc

Please sign in to comment.