import DiscordUtils import pafy import itertools from discord.ext import commands, tasks from ballreplies import replies from workreplies import wreplies from random import choice from os import system from music import Music from itertools import cycle from permissiondeniedreplies import preplies intents = discord.Intents.default() intents.members = True client = commands.Bot('$', intents=intents, description='Yet another music bot.') music = DiscordUtils.Music() status = cycle( ['Watching being worked on', 'Watching me causing the programmers pain']) earningRange = 18 @client.event async def on_ready(): print(f"Init as {client.user}") change_status.start() @tasks.loop(minutes=20)
from __future__ import annotations import discord from discord.ext import commands from discord.ext.commands import HelpCommand from const import COMMAND_PREFIX from private import TOKEN from events import BotEvents, BotStartEvents, CommandEvents, locks from commands import Action, Display from help import CustomHelp if __name__ == "__main__": intents = discord.Intents().all() bot = commands.Bot(command_prefix=COMMAND_PREFIX, intents=intents, case_insensitive=True) bot.add_cog(BotEvents(bot)) bot.add_cog(BotStartEvents(bot)) bot.add_cog(CommandEvents(bot)) bot.add_cog(Action(bot)) bot.add_cog(Display(bot)) bot.help_command = CustomHelp() bot.run(TOKEN)
import subprocess from itertools import islice import discord from discord.ext import commands def get_prefix(bot, message): try: return ['ca.'] + ([('!', ';')[bot.user.id == 376485072561504257]] if message.guild.id == 357922255553953794 else []) except AttributeError as e: # if in DMs, message.guild is None and therefore has no attribute 'id' return '!' #TODO: override commands.Bot.get_prefix to allow this to be '' bot = commands.Bot(command_prefix=get_prefix) bot.remove_command('help') @bot.event async def on_ready(): bot.logs = collections.deque(maxlen=100) bot.logtask = bot.loop.create_task(get_heroku_logs()) print('Logbot ready!') async def get_heroku_logs(): with subprocess.Popen('./open-logs.sh', stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) as proc:
import requests import discord from discord.ext import commands import requests import bs4 from selenium import webdriver import shutil client = commands.Bot(command_prefix = ".") @client.event async def on_ready(): print("Pokemon Bot is ready!") @client.command(pass_context=True) async def clear(ctx,amount=1): channel = ctx.message.channel messages = await channel.history(limit=int(amount)).flatten() await channel.delete_messages(messages) @client.event async def on_message(message): Invalid_name=0 if message.content.startswith(".find"): url = "https://pokemon-go1.p.rapidapi.com/pokemon_stats.json" Pokemon_name = message.content.split() Pokemon_name = Pokemon_name[-1] headers = { 'x-rapidapi-host': "pokemon-go1.p.rapidapi.com", 'x-rapidapi-key': "d088b6503bmshdc714a4f2084684p1fa298jsne50d46634631"
import discord import os from discord.ext import commands Client = discord.Client() client = commands.Bot(command_prefix='>') players = {} # sounds = 'ahem, breathing, zvuv, lishtok, kafa, patachta, joke, mafchid, lololo, tikanes, mishlochim, yerakot, beita, beita_lapanim, bo_bo, oink, pokemon_go' # On Windows # if not discord.opus.is_loaded(): # discord.opus.load_opus("opusenc.exe") client.remove_command('help') @client.command(pass_context=True) async def play(ctx, file_name): server = ctx.message.server voice_client = client.voice_client_in(server) try: current_player = players[voice_client.session_id] if current_player.is_playing(): return 0 else: del players[voice_client.session_id] except: pass if voice_client:
import discord from WordFilter import Filter from discord.ext import commands from discord.ext.commands import has_permissions intents = discord.Intents.default() intents.members = True intents.reactions = True client = commands.Bot(command_prefix='!', intents=intents) f = Filter() # class holds blacklisted words @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) @client.command(aliases=['test', 'bot']) async def sirius(ctx): await ctx.send('Sirius at your service!') # welcome user @client.event async def on_member_join(member): channel = client.get_channel(773210226370805801) roles = client.get_channel(773646315900239892) await channel.send( f'Hello, {member.mention}! Welcome to **Andromeda!**\n**To get started,** visit {roles.mention} to choose a role!'
from discord.ext import commands import discord import manifest import ctypes ctypes.windll.kernel32.SetConsoleTitleW(manifest.terminal_name) bot = commands.Bot(command_prefix=manifest.prefix) bot.remove_command("help") [ bot.load_extension("Extensions." + extension) for extension in ["info", "credits", "gaming", "mod"] ] @bot.event async def on_ready(): await bot.change_presence(status=discord.Status.online, activity=discord.Activity( type=discord.ActivityType.listening, name="$info")) print(manifest.ready_message) bot.run(manifest.token)
import discord from discord.ext import commands import os import random TOKEN = os.environ.get('TOKEN', None) ## TOKEN required to run the bot ## Get at discordapp.com/developers/applications/me bot = commands.Bot(command_prefix='kadle.', description="", case_insensitive=True, owner_id=391864327398883329, help_command=None) @bot.event async def on_message(message): ## So that the bot does not reply to itself if message.author == bot.user: return if message.content.startswith('kadle.'): await bot.process_commands(message) @bot.event async def on_ready(): """Logs to console once it is ready. Creates directories which will be used in other cogs""" game = discord.Game("kadle.help")
import discord from discord.ext import commands import sqlite3 from config import settings TOKEN = settings['TOKEN'] client = commands.Bot(command_prefix=settings['PREFIX']) client.remove_command('help') bot_id = 774318806943793214 with sqlite3.connect('server.db') as conn: cursor = conn.cursor() #COMANDS @client.command() async def hi(ctx): await ctx.send("Привет всем :)") # отправляем обратно @client.command() @commands.has_permissions(administrator=True) async def clear(ctx, amount=100): amount += 1 await ctx.channel.purge(limit=amount) @client.command() async def update(ctx): await ctx.channel.purge(limit=1) await update()
import nekos import psutil as ps from Cybernator import Paginator from psutil import virtual_memory from io import BytesIO from PIL import Image,ImageFilter,ImageDraw,ImageFont client = commands.Bot(command_prefix = '?', intents = discord.Intents.all()) client.remove_command('help') @client.event async def on_ready(): print('Connected!') await client.change_presence( status = discord.Status.do_not_disturb, activity = discord.Game('YouTube Community')) @client.command() async def NAME(ctx): await ctx.send('Привет!') #kick
'Customer', 'Hobo', 'Boardgamer', 'Movie Goer', 'In Gambling Rehab', 'Assistant'] UNORDERABLE = ['Staff', 'Groovy', 'PythonApp', 'Pancake', 'Brewmaster', 'Apprentice', 'Pumpkin Spice Latte', 'Unlucky', 'Caffeine Addict', 'Regular', 'Customer', 'Hobo', 'Boardgamer', 'Movie Goer', 'Rythm', 'In Gambling Rehab', 'Server Booster', 'Assistant'] UNREMOVABLE = ['Customer', 'Hobo'] # LOGGING LOG_FORMAT = '%(levelname)s %(asctime)s - %(message)s' log_path = os.path.join(os.getcwd(), 'bot.log') logging.basicConfig(filename=log_path, level=logging.INFO, format=LOG_FORMAT) logger = logging.getLogger() print('starting up bot...') bot = commands.Bot(command_prefix='--') cogs = [ 'coffee', 'misc', 'confession', 'music' ] def get_json(file): with open(file, 'r', encoding='utf8') as f: users = json.load(f) return users def save_json(file, users): with open(file, 'w', encoding='utf8') as f:
def __init__(self): self.bot = commands.Bot(command_prefix=self.get_prefix) self.confing = File("config", format="json") self.list_of_users_logging = {} self.bot.remove_command("help") self._main_events()
from types import TracebackType from typing import List, Optional import discord from util import debug from discord.ext import commands import myHelpCommand import reaction import os import sys help_command: myHelpCommand.myHelpCommand = myHelpCommand.myHelpCommand() bot: commands.Bot = commands.Bot(command_prefix="./takashi ", help_command=help_command) def get_voice_client() -> discord.VoiceClient: global guild_id guild: discord.Guild = bot.get_guild(guild_id) cli: discord.VoiceClient = guild.voice_client return cli @bot.event async def on_ready(): debug.info("Logged in as") debug.info(bot.user.name) debug.info(bot.user.id) debug.info("------") def is_owner(user: discord.User) -> bool: global admin_id
import requests from discord.ext import commands from discord.utils import get try: from PIL import Image except ImportError: import Image pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe' token = 'ODA1NTY5MzQzNzIyMjI1NzA1.YBcy6g.epZi7sg-P7nc1UmafyJEF4iMvzI' intents = discord.Intents.default() intents.members = True bot = commands.Bot(command_prefix="!", description=None, intents=intents) bot.remove_command('help') @bot.event async def on_ready(): print('Logged in as') print(bot.user.name) print(bot.user.id) await bot.change_presence(activity=discord.Game('!help')) @bot.event async def on_member_join(ctx): nub = discord.utils.get(ctx.guild.roles, name="Nub") await ctx.add_roles(nub)
import requests from discord.ext import commands bot = commands.Bot(command_prefix="wtr ", description="Bot_meteo") @bot.event async def on_ready(): print("Connexion : OK") @bot.command() async def info(ctx, city): # url pour la ville adress = 'http://api.openweathermap.org/data/2.5/weather?appid=7eb7eebdc32e8e2def3bb47154c712d3&q=' url = adress + city #requete json try: json_data = requests.get(url).json() info = json_data['weather'][0]['description'] except KeyError: await ctx.send("Je ne trouve pas de ville de ce nom la ") pass # conversion degre kelvin / celsius temp = json_data['main']['temp'] temp = temp - 273 # pays country = json_data['sys']['country'] if country == 'FR':
load_dotenv() # if not os.path.exists('data/logs/'): # os.mkdir('data/logs/') # # logger=logging.getLogger('discord') # logger.setLevel(logging.DEBUG) # handler=logging.FileHandler( # filename=f'data/logs/{datetime.now().strftime("%Y-%m-%d")}.log', # encoding='utf-8', mode='w') # handler.setFormatter(logging.Formatter( # '%(asctime)s:%(levelname)s:%(name)s: %(message)s')) # logger.addHandler(handler) bot: commands.Bot=commands.Bot(command_prefix=['Maia ', 'maia ', 'MAIA ', 'Maia, ', 'maia, ', 'MAIA, ']) @bot.event async def on_ready() -> None: for guild in bot.guilds: get_cfg(guild) print(f'{bot.user.name}, rolling out in the age of {discord.__version__}!') with open('data/game.txt', 'r+', encoding='utf-8') as game_cfg: game: str=game_cfg.read() if game!='': await bot.change_presence(activity=discord.Game(game)) print(f'Playing: {game}') bot.add_cog(Fluff(bot))
# Define bot description = cleandoc(""" I'm a 2006 level 3 wc bot that Seltzer Bro keeps imprisoned on a flash drive. Please let me out. :( You can use !help <command> to get more information on said command. """) activity = discord.Game("Bustin' Bots", type=discord.ActivityType.watching) intents = discord.Intents(messages=True, guilds=True, members=True, reactions=True) bot = commands.Bot(allowed_mentions=discord.AllowedMentions(everyone=False, roles=False, users=True), command_prefix=os.getenv('COMMAND_PREFIX'), description=description, case_insensitive=True, activity=activity, intents=intents) # Discord Bot events @bot.event async def on_ready(): print(f"We have logged in as {bot.user}") @bot.event async def on_connect(): print("Bot connected successfully.")
# This example requires the 'members' privileged intents import discord from discord.ext import commands import random description = '''An example bot to showcase the discord.ext.commands extension module. There are a number of utility commands being showcased here.''' intents = discord.Intents.default() intents.members = True bot = commands.Bot(command_prefix='?', description=description, intents=intents) @bot.event async def on_ready(): print(f'Logged in as {bot.user} (ID: {bot.user.id})') print('------') @bot.command() async def add(ctx, left: int, right: int): """Adds two numbers together.""" await ctx.send(left + right)
def get_prefix(bot, message): """A callable Prefix for our bot. This could be edited to allow per server prefixes.""" # Notice how you can use spaces in prefixes. Try to keep them simple though. prefixes = ['$'] # Check to see if we are outside of a guild. e.g DM's etc. if not message.guild: # Only allow ? to be used in DMs return '$' # If we are in a guild, we allow for the user to mention us or use any of the prefixes in our list. return commands.when_mentioned_or(*prefixes)(bot, message) bot = commands.Bot(command_prefix=get_prefix, description='Version ' + str(OSBuid)) #load everything if __name__ == "__main__": cogs_dir = "Cogs" module_dir = "Modules" gbl = globals() #load all cogs #goes through each file in the cogs directory for extension in [f.replace('.py', '') for f in listdir(cogs_dir) if isfile(join(cogs_dir, f))]: try: #tries to load them bot.load_extension(cogs_dir + "." + extension) except Exception as e: #throws an error if it can't
import asyncio import discord import os from discord.ext import commands from discord.ext.commands import Bot Bot = commands.Bot(command_prefix=";") Warns = [] Citations = [] def GetRole(Guild, Name): Role = discord.utils.get(Guild.roles, name=Name) return Role def GetChannel(Guild, Name): Channel = discord.utils.get(Guild.channels, name=Name) return Channel def IsModerator(Guild, Member): Role = GetRole(Guild, "Server Moderator") for HasRoles in Member.roles: if Role == HasRoles: return True async def DM(Member, Text, Embed): try:
import discord import os import asyncio from discord.ext import tasks, commands from discord.utils import get from itertools import cycle prefix = './' #Comman prefix is setup here, this is what you have to type to issue a command to the bot bot = commands.Bot(command_prefix=prefix) #Removed the help command to create a custom help guide bot.remove_command('help') #Variable containing statuses for the bot to cycle through status = cycle(["status 1", "status 2", "status3"]) #|--------------------EVENTS--------------------| @bot.event async def on_ready(): #Enter any startup tasks here change_status.start() #This is printed in the console to notify the user that the bot is running correctly without error print("Bot is ready to use.") @bot.event async def on_member_join(member):
import asyncio import os import random import time from datetime import datetime from PIL import Image, ImageFilter import requests from io import BytesIO import inspect import praw import PIL.Image import pyspeedtest import sqlite3 from discord.http import Route bot = commands.Bot(command_prefix='n!') reddit = praw.Reddit( client_id='u3zBVRAgVJ8eOw', client_secret='_TeCQvme4Nj3GEpUCgS5nwgeJZE', user_agent='discord:u3zBVRAgVJ8eOw:v1.0 (by /u/BoringJelly)') bot.launch_time = datetime.utcnow() st = pyspeedtest.SpeedTest() conn = sqlite3.connect('users.db', isolation_level=None) c = conn.cursor() c.execute("""CREATE TABLE IF NOT EXISTS Users( UserID TEXT, Xp INT, PRIMARY KEY(UserID))""") developers = ['279714095480176642', '344404945359077377']
import discord from discord.ext import commands import config import os bot = commands.Bot(command_prefix='$') initial_extensions = ['cogs.destroyerbotwithcogs'] @bot.event async def on_ready(): await bot.change_presence(activity=discord.Activity( type=discord.ActivityType.watching, name="Destruction Happening")) if __name__ == '__main__': for extension in initial_extensions: bot.load_extension(extension) bot.run(config.token)
from discord.ext import commands bot = commands.Bot(command_prefix="!") class SomeCommands(commands.Cog): """A couple of simple commands""" def __init__(self, bot: commands.Bot): self.bot = bot @commands.command(name="ping") async def ping(self, ctx: commands.Context): """Get the bot's current websocket latency""" await ctx.send(f"Pong! {round(bot.latency * 1000)}ms") bot.add_cog(SomeCommands(bot)) bot.run("your_token_here")
import discord from discord.ext.commands import bot from discord import game from discord.ext import commands import asyncio import platform import colorsys import random import time client = commands.Bot(command_prefix='+', case_insensitive=True) Client = discord.client Clientdiscord = discord.Client() @client.event async def on_ready(): print('Logged in as ' + client.user.name + ' (ID:' + client.user.id + ') | Connected to ' + str(len(client.servers)) + ' servers | Connected to ' + str(len(set(client.get_all_members()))) + ' users') print('--------') print('--------') print('CREATED AND HOSTED BY twisted') @client.command(pass_context=True) @commands.has_permissions(kick_members=True) async def userinfo(ctx, user: discord.Member): r, g, b = tuple( int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
from discord.ext import commands from src.convertdata import sekantung_kata, kata, label, data, net import random import numpy import tflearn import sys args = sys.argv[1] model = tflearn.DNN(net) model.load('./src/model/model.tfl') client = commands.Bot(command_prefix='!union ') global is_on is_on = False @client.event async def on_message(msg): author = msg.author content = msg.content channel = msg.channel sender = channel debugchannel = client.get_channel("debug channel id") results = model.predict([sekantung_kata(content, kata)]) results_index = numpy.argmax(results) tag = label[results_index] for tg in data["intents"]:
import discord from discord.ext import commands import aiohttp import re from datetime import timedelta import traceback import os from random import choice, randint from config import token owner = ["222526329109741568", "252084047264743428"] version = "Ver. 0.1.29.3" bot = commands.Bot(command_prefix='p!', description=" I'm that demonic border collie from that television show.") @bot.event async def on_ready(): print('Mr. Pickles Discord Bot') print('Version:') print(version) print('Logged in as') print(bot.user.name) print('With ID:') print(bot.user.id) print('Number of Guilds:') print((len(bot.servers))) print('------') print('Invite me to your server:') print(discord.utils.oauth_url(bot.user.id)) await bot.change_presence(game=discord.Game(name='with my vaccum cleaner~ | p!help'))
import discord import sqlite3 from discord.ext import commands from config import settings bot=commands.Bot(command_prefix=settings['prefix']) connection = sqlite3.connect('server.db') cursor = connection.cursor() @bot.command() async def hello(ctx): author = ctx.message.author await ctx.send(f'Здравствуй говнарь {author.mention}!') @bot.event async def on_ready(): cursor.execute("""CREATE TABLE IF NOT EXISTS users( name TEXT, id INT, cash BIGINT, rep INT, lvl INT )""") for guild in bot.guilds: for member in guild.members: if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None: cursor.execute(f"INSERT INTO users VALUES ('{member}',{member.id}, 0, 0 , 1 )") else: pass connection.commit() print('Bot connected')
import discord from discord.ext import commands import random import asyncio import aiohttp import requests import reddit client = commands.Bot(command_prefix = 'idk ') client.remove_command('help') class MyHelpCommand(commands.MinimalHelpCommand): def get_command_signature(self, command): return '{0.clean_prefix}{1.qualified_name} {1.signature}'.format(self, command) class MyCog(commands.Cog): def __init__(self, bot): self._original_help_command = bot.help_command bot.help_command = MyHelpCommand() bot.help_command.cog = self def cog_unload(self): self.bot.help_command = self._original_help_command
import discord from discord.ext import commands from keep_alive import keep_alive import os bot = commands.Bot( command_prefix=commands.when_mentioned_or("n!", "N!"), description="DAMN BRO NO WAY IT's THE HELP SECTION!!!!!! BRUH!HH!H!H!H!!H", case_insensitive=True) @bot.event async def on_ready(): await bot.change_presence(status=discord.Status.idle, activity=discord.Activity( type=discord.ActivityType.playing, name="with my nuts tbh")) #tbh print("YUH COFFEE TIME BRUHHHHH COFFEEE MOMENT>>>>>>") extensions = ['cogs.bruh', 'cogs.owner'] if __name__ == '__main__': for extension in extensions: bot.load_extension(extension) keep_alive() token = os.getenv("BOT_TOKEN") bot.run(token)