modified: bot.py
This commit is contained in:
7
bot.py
7
bot.py
@@ -7,26 +7,20 @@ intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
bot = commands.Bot(command_prefix="!", intents=intents)
|
||||
|
||||
# Discord Token
|
||||
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
|
||||
# Channel ID to post messages
|
||||
CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
|
||||
|
||||
# Flask web server for posting updates
|
||||
app = Flask(__name__)
|
||||
|
||||
# Event when bot is ready
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
channel = bot.get_channel(CHANNEL_ID)
|
||||
await channel.send("Info-Bot is now online!")
|
||||
|
||||
# Command to manually post a message in Discord
|
||||
@bot.command()
|
||||
async def post(ctx, category: str, *, message: str):
|
||||
await ctx.send(f"**[{category.upper()}]** {message}")
|
||||
|
||||
# Flask route to post updates via Webhook
|
||||
@app.route("/webhook", methods=["POST"])
|
||||
def webhook():
|
||||
data = request.json
|
||||
@@ -53,7 +47,6 @@ async def post_manual(category, message):
|
||||
channel = bot.get_channel(CHANNEL_ID)
|
||||
await channel.send(f"**[{category.upper()}]** {message}")
|
||||
|
||||
# Start the Flask server in a separate thread
|
||||
def start_flask():
|
||||
app.run(host="0.0.0.0", port=os.getenv("PORT"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user