Skip to main content

A Python wrapper for the DisStat API.

Project description

Disstat

Disstat is a Python package for computing dissimilarity statistics for wrapping the Disstat API.

Installation

Use the package manager pip to install disstat.

pip install disstat

Usage

from discord import Intents, Interaction
from discord.ext import commands
from disstat import DisstatClient


class Bot(commands.Bot):
    def __init__(self):
        super().__init__(command_prefix="!", intents=Intents.default())
        self.disstat = DisstatClient(self, "DISSTAT API KEY HERE")

    async def on_ready(self):
        await self.disstat.start_auto_post()

    async def on_command_completion(
        self, ctx: commands.Context
    ):  # For using prefix commands
        await self.disstat.post_command(
            ctx.command.name,
            invoker_id=ctx.user.id,
            guild_id=(ctx.guild.id if ctx.guild else None),
        )

    async def on_app_command_completion(
        self, interaction: Interaction
    ):  # For using slash commands
        await self.disstat.post_command(
            interaction.command.name,
            invoker_id=interaction.user.id,
            guild_id=(interaction.guild.id if interaction.guild else None),
        )

    async def on_disstat_post(self, payload):
        print("Posted stats to Disstat.")

    async def on_disstat_post_command(self, payload):
        print(f"Posted command {payload['command']} to Disstat.")


bot = Bot()

bot.run("TOKEN")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

disstat-1.0.3.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file disstat-1.0.3.tar.gz.

File metadata

  • Download URL: disstat-1.0.3.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for disstat-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a0561ad1b0b3e5c97ee8468e61c295a1c0a155e902abbdd59f9f6a5caaeb3312
MD5 4b17fbbbee39efb56d693ba75a58301b
BLAKE2b-256 871ee36ac9e3e4497e439adaad328e289bdab39a7b17f73147eab0571a8678ec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page