Skip to content

Commit 925eeaa

Browse files
committed
add addr for localhost
1 parent d3ef4fd commit 925eeaa

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

bot/bot.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import nextcord
22
from nextcord.ext import commands
33
from shared.config import CHANNEL_ID, DISCORD_TOKEN, GUILD_ID
4-
from prometheus_client import start_http_server, Gauge
5-
import time
6-
7-
BOT_STATUS = Gauge('discord_bot_status', 'Status of the Discord bot', ['bot_name'])
8-
bot_name = 'Kernel'
4+
from main import BOT_STATUS, bot_name
95

106
# Create an instance of the bot with all intents enabled
117
intents = nextcord.Intents.all()
128
bot = commands.Bot(command_prefix="!", intents=intents)
139

14-
1510
async def clear_channel(channel):
1611
"""
1712
Clears all messages from the given channel.
@@ -50,20 +45,13 @@ async def on_ready():
5045
# Mark the bot as "up" when it is online
5146
BOT_STATUS.labels(bot_name=bot_name).set(1)
5247

53-
# Importing slash commands and context menus
54-
# from . import slash_commands, context_menus
5548

5649
@bot.event
5750
async def on_disconnect():
5851
print(f'{bot_name} has disconnected from Discord!')
5952
# Mark the bot as "down" when it is offline
6053
BOT_STATUS.labels(bot_name=bot_name).set(0)
6154

62-
def start_prometheus_server():
63-
# Start a Prometheus HTTP server on port 8000
64-
start_http_server(8000, addr='0.0.0.0')
65-
print("Prometheus server started on port 8000")
66-
6755
if __name__ == '__main__':
6856

6957
# Run the bot with the specified token

main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
from web.app import app
44
from shared.config import DISCORD_TOKEN, ENABLE_LOGGING
55
from shared.logger import setup_logging # Importing from your logger module
6+
from prometheus_client import start_http_server, Gauge
7+
import time
68

9+
BOT_STATUS = Gauge('discord_bot_status', 'Status of the Discord bot', ['bot_name'])
10+
bot_name = 'Kernel'
11+
12+
def start_prometheus_server():
13+
# Start a Prometheus HTTP server on port 8000
14+
start_http_server(8000, addr='0.0.0.0')
15+
print("Prometheus server started on port 8000")
716

817
def run():
918
app.run(port=9999)
@@ -22,5 +31,5 @@ def run():
2231
bot.load_extension('bot.news_feed')
2332
# bot.load_extension('bot.moderation') Turning off because it's not working
2433
# Start the bot
25-
bot.start_prometheus_server()
34+
start_prometheus_server()
2635
bot.run(DISCORD_TOKEN)

0 commit comments

Comments
 (0)