mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 19:58:54 -05:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
4008ae54d8
@ -2,6 +2,7 @@ import discord
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from .utils.dataIO import fileIO
|
from .utils.dataIO import fileIO
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
|
from __main__ import user_allowed
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class CustomCommands:
|
class CustomCommands:
|
||||||
@ -86,12 +87,25 @@ class CustomCommands:
|
|||||||
async def checkCC(self, message):
|
async def checkCC(self, message):
|
||||||
if message.author.id == self.bot.user.id or len(message.content) < 2 or message.channel.is_private:
|
if message.author.id == self.bot.user.id or len(message.content) < 2 or message.channel.is_private:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not user_allowed(message):
|
||||||
|
return
|
||||||
|
|
||||||
msg = message.content
|
msg = message.content
|
||||||
server = message.server
|
server = message.server
|
||||||
if msg[0] in self.bot.command_prefix and server.id in self.c_commands.keys():
|
prefix = self.get_prefix(msg)
|
||||||
|
|
||||||
|
if prefix and server.id in self.c_commands.keys():
|
||||||
cmdlist = self.c_commands[server.id]
|
cmdlist = self.c_commands[server.id]
|
||||||
if msg[1:] in cmdlist:
|
cmd = msg[len(prefix):]
|
||||||
await self.bot.send_message(message.channel, cmdlist[msg[1:]])
|
if cmd in cmdlist.keys():
|
||||||
|
await self.bot.send_message(message.channel, cmdlist[cmd])
|
||||||
|
|
||||||
|
def get_prefix(self, msg):
|
||||||
|
for p in self.bot.command_prefix:
|
||||||
|
if msg.startswith(p):
|
||||||
|
return p
|
||||||
|
return False
|
||||||
|
|
||||||
def check_folders():
|
def check_folders():
|
||||||
if not os.path.exists("data/customcom"):
|
if not os.path.exists("data/customcom"):
|
||||||
|
|||||||
72
red.py
72
red.py
@ -33,9 +33,17 @@ lock = False
|
|||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
users = str(len([m for m in bot.get_all_members()]))
|
||||||
|
servers = str(len(bot.servers))
|
||||||
|
channels = str(len([c for c in bot.get_all_channels()]))
|
||||||
print('------')
|
print('------')
|
||||||
print(bot.user.name + " is now online.")
|
print(bot.user.name + " is now online.")
|
||||||
print('------')
|
print('------')
|
||||||
|
print("Connected to:")
|
||||||
|
print(servers + " servers")
|
||||||
|
print(channels + " channels")
|
||||||
|
print(users + " users")
|
||||||
|
print("\n{0} active cogs with {1} commands\n".format(str(len(bot.cogs)), str(len(bot.commands))))
|
||||||
bot.uptime = int(time.perf_counter())
|
bot.uptime = int(time.perf_counter())
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
@ -44,35 +52,7 @@ async def on_command(command, ctx):
|
|||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
mod = bot.get_cog('Mod')
|
if user_allowed(message):
|
||||||
author = message.author
|
|
||||||
|
|
||||||
if mod is not None:
|
|
||||||
if checks.settings["OWNER"] == author.id:
|
|
||||||
await bot.process_commands(message)
|
|
||||||
return
|
|
||||||
if not message.channel.is_private:
|
|
||||||
if discord.utils.get(author.roles, name=checks.settings["ADMIN_ROLE"]) is not None:
|
|
||||||
await bot.process_commands(message)
|
|
||||||
return
|
|
||||||
if discord.utils.get(author.roles, name=checks.settings["MOD_ROLE"]) is not None:
|
|
||||||
await bot.process_commands(message)
|
|
||||||
return
|
|
||||||
|
|
||||||
if author.id in mod.blacklist_list:
|
|
||||||
return
|
|
||||||
|
|
||||||
if mod.whitelist_list:
|
|
||||||
if author.id not in mod.whitelist_list:
|
|
||||||
return
|
|
||||||
|
|
||||||
if not message.channel.is_private:
|
|
||||||
if message.server.id in mod.ignore_list["SERVERS"]:
|
|
||||||
return
|
|
||||||
|
|
||||||
if message.channel.id in mod.ignore_list["CHANNELS"]:
|
|
||||||
return
|
|
||||||
|
|
||||||
await bot.process_commands(message)
|
await bot.process_commands(message)
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
@ -212,6 +192,38 @@ async def _uptime():
|
|||||||
up = str(datetime.timedelta(seconds=up))
|
up = str(datetime.timedelta(seconds=up))
|
||||||
await bot.say("`Uptime: {}`".format(up))
|
await bot.say("`Uptime: {}`".format(up))
|
||||||
|
|
||||||
|
def user_allowed(message):
|
||||||
|
|
||||||
|
author = message.author
|
||||||
|
|
||||||
|
mod = bot.get_cog('Mod')
|
||||||
|
|
||||||
|
if mod is not None:
|
||||||
|
if checks.settings["OWNER"] == author.id:
|
||||||
|
return True
|
||||||
|
if not message.channel.is_private:
|
||||||
|
if discord.utils.get(author.roles, name=checks.settings["ADMIN_ROLE"]) is not None:
|
||||||
|
return True
|
||||||
|
if discord.utils.get(author.roles, name=checks.settings["MOD_ROLE"]) is not None:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if author.id in mod.blacklist_list:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if mod.whitelist_list:
|
||||||
|
if author.id not in mod.whitelist_list:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not message.channel.is_private:
|
||||||
|
if message.server.id in mod.ignore_list["SERVERS"]:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if message.channel.id in mod.ignore_list["CHANNELS"]:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def wait_for_answer(author):
|
def wait_for_answer(author):
|
||||||
global lock
|
global lock
|
||||||
print(author.name + " requested to be set as owner. If this is you, type 'yes'. Otherwise press enter.")
|
print(author.name + " requested to be set as owner. If this is you, type 'yes'. Otherwise press enter.")
|
||||||
@ -333,7 +345,7 @@ def load_cogs():
|
|||||||
register = tuple(data.keys()) #known cogs
|
register = tuple(data.keys()) #known cogs
|
||||||
extensions = list_cogs()
|
extensions = list_cogs()
|
||||||
|
|
||||||
if extensions: print("\nLoading cogs...")
|
if extensions: print("\nLoading cogs...\n")
|
||||||
|
|
||||||
failed = []
|
failed = []
|
||||||
for extension in extensions:
|
for extension in extensions:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user