Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d81b143a3f | |||
| ef23f07479 | |||
| 30fb36d61a | |||
| fffbc08a82 | |||
| b13e574427 | |||
| 0ed3072b44 | |||
| f335f193b8 | |||
| aba1b10ef1 | |||
| daaededd19 | |||
| ac7d4a1191 | |||
| 16e1cade57 |
@@ -1,4 +1,4 @@
|
|||||||
name: Test
|
name: Python
|
||||||
|
|
||||||
on: ["push", "pull_request"]
|
on: ["push", "pull_request"]
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.8, 3.9]
|
python-version: [3.7, 3.8, 3.9]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
@@ -17,16 +17,13 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install flake8 black
|
python -m pip install flake8
|
||||||
- name: Lint with flake8
|
- name: Lint with flake8
|
||||||
run: |
|
run: |
|
||||||
# stop the build if there are Python syntax errors or undefined names
|
# stop the build if there are Python syntax errors or undefined names
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
- name: Code style with black
|
|
||||||
run: |
|
|
||||||
black --check
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ The function must be exactly named after the event
|
|||||||
```python
|
```python
|
||||||
async def on_ready() -> bool:
|
async def on_ready() -> bool:
|
||||||
print("on_ready")
|
print("on_ready")
|
||||||
return False # if True is returned, prevent miniscord handling of the event
|
return True # if False is returned, prevent miniscord's handling of the event
|
||||||
|
|
||||||
bot.register_event(on_ready)
|
bot.register_event(on_ready)
|
||||||
```
|
```
|
||||||
@@ -344,6 +344,7 @@ bot.start() # this bot respond to "|help", "|info" and "|hello"
|
|||||||
|
|
||||||
## Versions
|
## Versions
|
||||||
|
|
||||||
|
* v0.1.0 : Discord v2 API with intents
|
||||||
* v0.0.3 : custom events handling
|
* v0.0.3 : custom events handling
|
||||||
* v0.0.2 : new answer capability
|
* v0.0.2 : new answer capability
|
||||||
* v0.0.1 : initial version
|
* v0.0.1 : initial version
|
||||||
|
|||||||
+9
-6
@@ -59,11 +59,14 @@ class Bot(object):
|
|||||||
self.__commands = []
|
self.__commands = []
|
||||||
self.__fallback = None
|
self.__fallback = None
|
||||||
self.__events = {}
|
self.__events = {}
|
||||||
self.games = [f"v{version}", lambda: f"{len(self.client.guilds)} guilds"]
|
self.games = [f"v{version}", lambda: f"{len(self.guilds)} guilds"]
|
||||||
if self.alias is not None:
|
if self.alias is not None:
|
||||||
self.games += [f"{self.alias}help"]
|
self.games += [f"{self.alias}help"]
|
||||||
self.client = discord.Client()
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
self.client = discord.Client(intents=intents)
|
||||||
self.client.bot = self
|
self.client.bot = self
|
||||||
|
self.guilds = []
|
||||||
self.__register_events()
|
self.__register_events()
|
||||||
self.__register_commands()
|
self.__register_commands()
|
||||||
|
|
||||||
@@ -106,7 +109,7 @@ class Bot(object):
|
|||||||
f"```\n"
|
f"```\n"
|
||||||
f"{self.app_name} v{self.version}\n"
|
f"{self.app_name} v{self.version}\n"
|
||||||
f"* Started at {self.__t0:%Y-%m-%d %H:%M}\n"
|
f"* Started at {self.__t0:%Y-%m-%d %H:%M}\n"
|
||||||
f"* Connected to {len(self.client.guilds)} guilds\n"
|
f"* Connected to {len(self.guilds)} guilds\n"
|
||||||
f"```",
|
f"```",
|
||||||
reference=message if self.answer else None,
|
reference=message if self.answer else None,
|
||||||
mention_author=self.answer_mention,
|
mention_author=self.answer_mention,
|
||||||
@@ -154,15 +157,15 @@ class Bot(object):
|
|||||||
async def on_ready(self, *args):
|
async def on_ready(self, *args):
|
||||||
if await self.__handle_event("on_ready", args):
|
if await self.__handle_event("on_ready", args):
|
||||||
return
|
return
|
||||||
|
self.guilds = [guild async for guild in self.client.fetch_guilds(limit=1000)]
|
||||||
# Change status
|
# Change status
|
||||||
logging.info(
|
logging.info(
|
||||||
f"{self.client.user} (v{self.version}) has connected to {len(self.client.guilds)} Discord guilds"
|
f"{self.client.user} (v{self.version}) has connected to {len(self.guilds)} Discord guilds"
|
||||||
)
|
)
|
||||||
if self.guild_logs_file is not None and not os.path.exists(
|
if self.guild_logs_file is not None and not os.path.exists(
|
||||||
self.guild_logs_file
|
self.guild_logs_file
|
||||||
):
|
):
|
||||||
for guild in self.client.guilds:
|
for guild in self.guilds:
|
||||||
await self.on_guild_join(guild)
|
await self.on_guild_join(guild)
|
||||||
while True:
|
while True:
|
||||||
await self.client.change_presence(
|
await self.client.change_presence(
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
discord.py
|
discord.py>=2.0.0
|
||||||
python-dotenv
|
python-dotenv
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="miniscord-Klemek",
|
name="miniscord-Klemek",
|
||||||
version="0.0.3",
|
version="0.1.0",
|
||||||
author="Klemek",
|
author="Klemek",
|
||||||
description="A minimalist discord bot API",
|
description="A minimalist discord bot API",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
|||||||
Reference in New Issue
Block a user