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"]
|
||||
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8, 3.9]
|
||||
python-version: [3.7, 3.8, 3.9]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
@@ -17,16 +17,13 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install flake8 black
|
||||
python -m pip install flake8
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# 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
|
||||
- name: Code style with black
|
||||
run: |
|
||||
black --check
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
@@ -49,4 +46,4 @@ jobs:
|
||||
run: coveralls
|
||||
env:
|
||||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -192,7 +192,7 @@ The function must be exactly named after the event
|
||||
```python
|
||||
async def on_ready() -> bool:
|
||||
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)
|
||||
```
|
||||
@@ -344,6 +344,7 @@ bot.start() # this bot respond to "|help", "|info" and "|hello"
|
||||
|
||||
## Versions
|
||||
|
||||
* v0.1.0 : Discord v2 API with intents
|
||||
* v0.0.3 : custom events handling
|
||||
* v0.0.2 : new answer capability
|
||||
* v0.0.1 : initial version
|
||||
|
||||
+9
-6
@@ -59,11 +59,14 @@ class Bot(object):
|
||||
self.__commands = []
|
||||
self.__fallback = None
|
||||
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:
|
||||
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.guilds = []
|
||||
self.__register_events()
|
||||
self.__register_commands()
|
||||
|
||||
@@ -106,7 +109,7 @@ class Bot(object):
|
||||
f"```\n"
|
||||
f"{self.app_name} v{self.version}\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"```",
|
||||
reference=message if self.answer else None,
|
||||
mention_author=self.answer_mention,
|
||||
@@ -154,15 +157,15 @@ class Bot(object):
|
||||
async def on_ready(self, *args):
|
||||
if await self.__handle_event("on_ready", args):
|
||||
return
|
||||
|
||||
self.guilds = [guild async for guild in self.client.fetch_guilds(limit=1000)]
|
||||
# Change status
|
||||
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(
|
||||
self.guild_logs_file
|
||||
):
|
||||
for guild in self.client.guilds:
|
||||
for guild in self.guilds:
|
||||
await self.on_guild_join(guild)
|
||||
while True:
|
||||
await self.client.change_presence(
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
discord.py
|
||||
discord.py>=2.0.0
|
||||
python-dotenv
|
||||
|
||||
Reference in New Issue
Block a user