Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: black

on:
push:

jobs:
formatter:
name: formatter
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8.14]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org/ | python
- name: Add path for Poetry
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Install Dependencies
run: poetry install --no-interaction
- name: black
run: poetry run black .
- name: autoflake
run: poetry run autoflake -r .
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
with:
commit_message: Apply Code Formatter Change
ref: ${{ github.head_ref }}
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pipenv
pip install flake8
- name: Lint with flake8
run: |
flake8 . --count --ignore=E501,E722,C901 --select=E9,F63,F7,F82 --show-source --statistics
Expand Down
26 changes: 26 additions & 0 deletions cogs/bot_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import discord
from discord.ext import commands
from discord import app_commands
from replit import db

def bot_command_count_get(data):
return db[f"bot_command_{data}_count_db"]

def bot_command_all_count_db_get():
return db[f"bot_command_all_count_db"]


class bot_info(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot: commands.Bot = bot

@app_commands.command(
name="bot_info",
description="Botの情報を表示します。"
)
async def botinfo(
self, i: discord.Interaction
):
await i.response.send_message(embed=discord.Embed(title='Botの情報').add_field(name='全コマンドの合計実行数', value=str(bot_command_all_count_db_get())), ephemeral=True)
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(bot_info(bot))
33 changes: 33 additions & 0 deletions cogs/bot_process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import discord
from discord.ext import commands
from discord import app_commands
from replit import db

def bot_command_count_get(data):
return db[f"bot_command_{data}_count_db"]

def bot_command_count(data):
db[f"bot_command_{data}_count_db"] = int(bot_command_count_get()) + 1

def bot_command_all_count_db_get():
return db[f"bot_command_all_count_db"]

def bot_command_count_p1():
db[f"bot_command_all_count_db"] = int(bot_command_all_count_db_get()) + 1


class bot_process(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot: commands.Bot = bot

@commands.Cog.listener(name='on_interaction')
async def interaction(self, i: discord.Interaction):
if i.type == discord.InteractionType.application_command:
bot_command_count_p1()
if self.bot.tree.get_command(i.command.name):
bot_command_count(i.command.name)
else:
return

async def setup(bot: commands.Bot) -> None:
await bot.add_cog(bot_process(bot))
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "EightBot"
version = "2.0.0"
description = ""
authors = ["EightBotDev <eightbot1644@gmail.com>"]

[tool.poetry.dependencies]
python = ">=3.8.0,<3.9"
numpy = "^1.22.2"
Flask = "^2.2.0"
urllib3 = "^1.26.12"
discord = "^2.0.0"
requests = "^2.28.1"
black = "^22.10.0"
autoflake = "^1.7.7"