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.217]) by gnuweeb.org (Postfix) with ESMTPSA id 45C107E257; Mon, 3 Oct 2022 23:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664841201; bh=rGqJc8CospGN8kl+i/2L674ck2Ij1/XcAuD3irILbmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dPobiZE2rrCDXQGHYTCGqm8xVYO6EYf8wpNm0m+w4fmFY4DK0r5Xf10xq6UM3Tenl KAolopVBgVWbIoSnCWnDHr/oeEuZIINCtHPjeS65hk6CmQhIEsXLVRHiioJDD6pFzf 2DOfH6zOvZTj8+TLkfEJaRAEvz7X2QPBkBVjdYi/HZT/4cUc/bG+LuqAZhOEiHKDXx hRZAGWuuwzl6/Nh9muaOlFFkqeW94A6ZOwR2C5CJ7j7T06q/eKm2F0eOl1nlgZYnhg ToMcWY9ZRC9aME5/w4hLbE7u6Cu246iVHVpFsenxbgpVZyhlSMznJgOeQx2EFCG6m4 LCzTDhISy4GjA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 13/28] discord: Use the created DB() class Date: Tue, 4 Oct 2022 06:52:14 +0700 Message-Id: <20221003235230.1824-14-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221003235230.1824-1-kiizuha@gnuweeb.org> References: <20221003235230.1824-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