public inbox for [email protected]
 help / color / mirror / Atom feed
From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [RFC PATCH v5 18/18] discord: Add $sync basic command
Date: Mon, 26 Sep 2022 04:14:27 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Add $sync basic command to be able to sync the slash commands to be a
global command.

How to use:
Just send a message `$sync` or `.sync` to the Discord channel that
contain your bot.

Prefixes: `$`, `.`
Aliases: `sync`, `s`

Signed-off-by: Muhammad Rizki <[email protected]>
---
 daemon/dscord/gnuweeb/plugins/__init__.py     |  3 +++
 .../plugins/basic_commands/__init__.py        | 11 ++++++++++
 .../gnuweeb/plugins/basic_commands/sync_it.py | 20 +++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 daemon/dscord/gnuweeb/plugins/basic_commands/__init__.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/basic_commands/sync_it.py

diff --git a/daemon/dscord/gnuweeb/plugins/__init__.py b/daemon/dscord/gnuweeb/plugins/__init__.py
index ab4cb7f..cbec2b5 100644
--- a/daemon/dscord/gnuweeb/plugins/__init__.py
+++ b/daemon/dscord/gnuweeb/plugins/__init__.py
@@ -5,10 +5,13 @@
 
 
 from discord.ext import commands
+
 from .events import Events
+from .basic_commands import BasicCommands
 
 
 class Plugins(
+	BasicCommands,
 	Events
 ): pass
 
diff --git a/daemon/dscord/gnuweeb/plugins/basic_commands/__init__.py b/daemon/dscord/gnuweeb/plugins/basic_commands/__init__.py
new file mode 100644
index 0000000..7ac825f
--- /dev/null
+++ b/daemon/dscord/gnuweeb/plugins/basic_commands/__init__.py
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022  Muhammad Rizki <[email protected]>
+#
+
+from .sync_it import SyncCommand
+
+
+class BasicCommands(
+	SyncCommand
+): pass
diff --git a/daemon/dscord/gnuweeb/plugins/basic_commands/sync_it.py b/daemon/dscord/gnuweeb/plugins/basic_commands/sync_it.py
new file mode 100644
index 0000000..fbaec03
--- /dev/null
+++ b/daemon/dscord/gnuweeb/plugins/basic_commands/sync_it.py
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022  Muhammad Rizki <[email protected]>
+#
+
+from discord.ext import commands
+
+
+class SyncCommand(commands.Cog):
+	def __init__(self, bot: "commands.Bot") -> None:
+		self.bot = bot
+
+
+	@commands.command("sync", aliases=["s"])
+	@commands.is_owner()
+	async def sync_it(self, ctx: "commands.Context"):
+		self.bot.tree.copy_global_to(guild=ctx.guild)
+		s = await self.bot.tree.sync(guild=ctx.guild)
+
+		await ctx.send(f"Synced {len(s)} commands.")
-- 
Muhammad Rizki


  parent reply	other threads:[~2022-09-25 21:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 21:14 [RFC PATCH v5 00/18] Refactor Telegram & initial work Discord Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 01/18] telegram: Move the Telegram bot source code Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 02/18] telegram: Refactor the Telegram bot database method Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 03/18] telegram: Rename some functions in scraper/bot.py Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 04/18] Add ignore file for .env Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 05/18] telegram: Refactor the Telegram bot Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 06/18] telegram: Renames in telegram mailer directory Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 07/18] Move scraper and utility file Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 08/18] discord: Initial work for the Discord bot Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 09/18] discord: Add success run notice on_ready event Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 10/18] discord: Add error handler on events Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 11/18] Move db.sql to combine the database with Discord and Telegram Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 12/18] discord: Add database tables for the Discord bot Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 13/18] discord: Add initial Discord bot database instance Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 14/18] discord: Add save_atom() in database insertion Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 15/18] discord: Add save_broadcast() " Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 16/18] discord: Add save_discord_mail() " Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 17/18] discord: Add save_email() " Muhammad Rizki
2022-09-25 21:14 ` Muhammad Rizki [this message]
2022-09-25 21:31 ` [RFC PATCH v5 00/18] Refactor Telegram & initial work Discord Ammar Faizi
2022-09-25 21:37   ` Muhammad Rizki
2022-09-25 21:48     ` Ammar Faizi
2022-09-25 21:52       ` Muhammad Rizki
2022-09-25 21:58         ` Ammar Faizi
2022-09-30 12:21           ` Ammar Faizi
2022-09-30 13:39             ` Muhammad Rizki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox