Small fixes
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
from miniscord import Bot
|
from miniscord import Bot
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
|
|
||||||
async def hello(client: discord.client, message: discord.Message):
|
async def hello(client: discord.client, message: discord.Message):
|
||||||
await message.channel.send("Hello!")
|
await message.channel.send("Hello!")
|
||||||
|
|
||||||
@@ -22,12 +23,12 @@ bot.register_command(
|
|||||||
"hello", # command text (regex)
|
"hello", # command text (regex)
|
||||||
hello, # command function
|
hello, # command function
|
||||||
"hello: says 'Hello!'", # short help
|
"hello: says 'Hello!'", # short help
|
||||||
f"```\n" # long help
|
"```\n" # long help
|
||||||
f"* |help\n"
|
"* |help\n"
|
||||||
f"\tSays 'Hello!'.\n"
|
"\tSays 'Hello!'.\n"
|
||||||
f"```"
|
"```"
|
||||||
)
|
)
|
||||||
bot.start() # this bot respond to "|help", "|info" and "|hello"
|
bot.start() # this bot respond to "|help", "|info" and "|hello"
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@@ -275,9 +276,10 @@ async def hello(client: discord.client, message: discord.Message, *args: str):
|
|||||||
'''
|
'''
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
await message.channel.send(f"Hello {args[1]}!")
|
await message.channel.send(f"Hello {args[1]}!")
|
||||||
else :
|
else:
|
||||||
await message.channel.send("Hello stranger!")
|
await message.channel.send("Hello stranger!")
|
||||||
|
|
||||||
|
|
||||||
async def mention(client: discord.client, message: discord.Message, *args: str):
|
async def mention(client: discord.client, message: discord.Message, *args: str):
|
||||||
channels[channel_id(message)] += 1
|
channels[channel_id(message)] += 1
|
||||||
senders[sender_id(message)] += 1
|
senders[sender_id(message)] += 1
|
||||||
@@ -286,6 +288,7 @@ async def mention(client: discord.client, message: discord.Message, *args: str):
|
|||||||
f"{channels[channel_id(message)]} mentions on this channel so far"
|
f"{channels[channel_id(message)]} mentions on this channel so far"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def message(client: discord.client, message: discord.Message):
|
async def message(client: discord.client, message: discord.Message):
|
||||||
if "catapult" in message.content:
|
if "catapult" in message.content:
|
||||||
sent_msg = await message.channel.send(f"{message.author.mention} No profanity on this server")
|
sent_msg = await message.channel.send(f"{message.author.mention} No profanity on this server")
|
||||||
@@ -304,10 +307,10 @@ bot.register_command(
|
|||||||
"hello", # command text (regex)
|
"hello", # command text (regex)
|
||||||
hello, # command function
|
hello, # command function
|
||||||
"hello: says 'Hello!'", # short help
|
"hello: says 'Hello!'", # short help
|
||||||
f"```\n" # long help
|
"```\n" # long help
|
||||||
f"* |help\n"
|
"* |help\n"
|
||||||
f"\tSays 'Hello!'.\n"
|
"\tSays 'Hello!'.\n"
|
||||||
f"```"
|
"```"
|
||||||
)
|
)
|
||||||
|
|
||||||
bot.register_fallback(mention) # the bot was mentioned or the alias was used
|
bot.register_fallback(mention) # the bot was mentioned or the alias was used
|
||||||
|
|||||||
+6
-6
@@ -8,7 +8,7 @@ import asyncio
|
|||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv, find_dotenv
|
||||||
|
|
||||||
from ._utils import sanitize_input, parse_arguments
|
from ._utils import sanitize_input, parse_arguments
|
||||||
|
|
||||||
@@ -105,10 +105,10 @@ class Bot(object):
|
|||||||
if len(args) <= 1:
|
if len(args) <= 1:
|
||||||
tmp_alias = '' if self.alias is None else self.alias
|
tmp_alias = '' if self.alias is None else self.alias
|
||||||
await message.channel.send(
|
await message.channel.send(
|
||||||
f"```\n"
|
"```\n"
|
||||||
f"List of available commands:\n" +
|
"List of available commands:\n"
|
||||||
"".join([f"* {tmp_alias}{command.help_short}\n" for command in self.__commands]) +
|
+ "".join([f"* {tmp_alias}{command.help_short}\n" for command in self.__commands])
|
||||||
f"```"
|
+ "```"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
for command in self.__commands:
|
for command in self.__commands:
|
||||||
@@ -210,7 +210,7 @@ class Bot(object):
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
logging.info(f"Current PID: {os.getpid()}")
|
logging.info(f"Current PID: {os.getpid()}")
|
||||||
env_file_found = load_dotenv()
|
env_file_found = load_dotenv(find_dotenv())
|
||||||
self.__token = os.getenv(self.token_env_var)
|
self.__token = os.getenv(self.token_env_var)
|
||||||
if self.__token is None:
|
if self.__token is None:
|
||||||
if env_file_found:
|
if env_file_found:
|
||||||
|
|||||||
Reference in New Issue
Block a user