From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.177]) by gnuweeb.org (Postfix) with ESMTPSA id 2EAE3804FD; Sat, 1 Oct 2022 13:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664629483; bh=rGqJc8CospGN8kl+i/2L674ck2Ij1/XcAuD3irILbmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tqXWiXAQrIz0MhL4w09M+HF+IfqDGG+CxOa8lxuYPKpuSK0bLnmvgxm3gA9WtrqeS jA/OSTjkTH7oFldYjlxTHO74HCq3pOGYkRWuFzGxbJ9njIkJXHNNbB3W029I7oTCnt 1s97B5HkaU+2e9sPp5RfSBm7iSBl0xbm5nYh+VmlZJOQD7XTnFJMvrRF/OlXIC37Ql zsjEDjIaRtN08+zrmVcDmiUfQB9M+4TbRoONSIuvStPXJsFRY61zFm9+mV+I3wdcwC 8pnhlACBtqRvxiDhu8PlAXovpMsDtyZhqEvLIVNrVfwsDbYuDwHA5r6OAgdnYc5DZT t9atF5vkLZKdg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 11/26] discord: Use the created DB() class Date: Sat, 1 Oct 2022 20:03:39 +0700 Message-Id: <20221001130355.784-12-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221001130355.784-1-kiizuha@gnuweeb.org> References: <20221001130355.784-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Use the DB() class into the __init__() function of the GWClient() class and add the MySQL connection to the GWClient() class parameter. Signed-off-by: Muhammad Rizki --- daemon/dc.py | 10 +++++++++- daemon/dscord/gnuweeb/client.py | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/daemon/dc.py b/daemon/dc.py index ff29abe..9b86df2 100644 --- a/daemon/dc.py +++ b/daemon/dc.py @@ -5,6 +5,7 @@ import os from dotenv import load_dotenv +from mysql import connector from dscord.gnuweeb import GWClient @@ -12,7 +13,14 @@ from dscord.gnuweeb import GWClient def main(): load_dotenv("discord.env") - client = GWClient() + client = GWClient( + db_conn=connector.connect( + host=os.getenv("DB_HOST"), + user=os.getenv("DB_USER"), + password=os.getenv("DB_PASS"), + database=os.getenv("DB_NAME") + ) + ) client.run(os.getenv("DISCORD_TOKEN"), log_handler=None) diff --git a/daemon/dscord/gnuweeb/client.py b/daemon/dscord/gnuweeb/client.py index fa07fb1..7893f88 100644 --- a/daemon/dscord/gnuweeb/client.py +++ b/daemon/dscord/gnuweeb/client.py @@ -8,9 +8,12 @@ from discord.ext import commands from discord import Intents from dscord.config import ACTIVITY_NAME +from dscord.database import DB + class GWClient(commands.Bot): - def __init__(self) -> None: + def __init__(self, db_conn) -> None: + self.db = DB(db_conn) intents = Intents.default() intents.message_content = True super().__init__( -- Muhammad Rizki