async def gamemodes(self, ctx): """Vote for today's gamemodes""" toscd = discord.Server(id='288455332173316106') emoteLib = discord.Server(id='401122122400923648') optinrole = discord.Role(id='358655924342095874', server='288455332173316106') auth = str(ctx.message.author.id) animpartyblob1 = discord.Emoji(name='animpartyblob1', server=emoteLib) classic = discord.Emoji(id='406242997852700672', server=toscd) rp = discord.Emoji(id='406242997903163392', server=toscd) custom = discord.Emoji(id='406242997584396299', server=toscd) eve = discord.Emoji(id='406242997492252674', server=toscd) rm = discord.Emoji(id='406242997727133697', server=toscd) aa = discord.Emoji(id='406242998205153298', server=toscd) mr = discord.Emoji(id='406242998083649546', server=toscd) await self.bot.edit_role(toscd, optinrole, name="Coven Notifications", colour=discord.Colour(0x550a94), mentionable=True) msg = await self.bot.say( """<a:animpartyblob1:401122373236948993> <a:animpartyblob2:401122373367234570> <a:animpartyblob3:401122373396463616> <a:animpartyblob4:401122373262376971> <a:animpartyblob5:401122373425823744> <a:animpartyblob6:401122373614567434> <a:animpartyblob7:401122373698322432> <a:animpartyblob8:401122373270503427> <a:animpartyblob9:401122373434343431> <@&358655924342095874> **||** We're voting for today's coven gamemodes! React to a gamemode to react. You may choose more than 1. **You may choose from these options:** <:CovenNormalClassic:406242997852700672> - Classic. <:CovenRankedPractice:406242997903163392> - Ranked Practice. <:CovenCustomCustom:406242997584396299> - Custom. <:CovenEvilsVEvils:406242997492252674> - Evils v Evils. <:CovenAllAny:406242997727133697> - All Any. <:CovenMafiaReturns:406242998083649546> - Mafia Returns <:CovenRotating:406242998205153298> - Rotating Gamemode (VIP or Lovers.) """) await self.bot.edit_role(toscd, optinrole, name="Coven Notifications", colour=discord.Colour(0x550a94), mentionable=False) await self.bot.add_reaction(msg, classic) await self.bot.add_reaction(msg, rp) await self.bot.add_reaction(msg, custom) await self.bot.add_reaction(msg, eve) await self.bot.add_reaction(msg, rm) await self.bot.add_reaction(msg, mr) await self.bot.add_reaction(msg, aa) def save(self): dataIO.save_json("data/hostdata/data.json", self.db)
async def invite(ctx): await bot.say(discord.Server(name='mirkan1', id=402192055767531530)) await bot.say( bot.invites_from(discord.Server(name='mirkan1', id=402192055767531530))) print( bot.invites_from(discord.Server(name='mirkan1', id=402192055767531530))) print(discord.Server(name='mirkan1', id=402192055767531530))
async def access(ctx): if ctx.message.channel.id == "439139494684262400": member = ctx.message.author await bot.delete_message(ctx.message) if discord.Role(server=discord.Server(id=server), id="439138951916290059") not in member.roles: await bot.add_roles( member, discord.Role(server=discord.Server(id=server), id=439138951916290059)) await bot.send_message( member, "You have recieved access! The IP for the server is starquest.spacebeaverstudios.com. Click this link to see more info about StarQuest and how to get the resource pack! <https://discordapp.com/channels/160246330701250560/351432162232500225?jump=394914296796151808>" )
def __init__(self, configs): # event bus and loop self.main_loop = asyncio.get_event_loop() self.bus = EventBus() # mongo db free4all connect('secret') self.mongo_db = Document._get_db() # discord self.discord_client = discord.Client() self.secret_server = discord.Server(id='326095959173890059') self.secret_channel = discord.Channel(id='404630967257530372', server=self.secret_server) self.welcome_channel = discord.Channel(id='404795628019777557', server=self.secret_server) # github self.git_client = Github(configs['github_username'], configs['github_password']) self.git_repo = self.git_client.get_repo('secRetDBot/secRet_dBot') self.web_repo = self.git_client.get_repo('secRetDBot/secRet-bot-frontend') # discord message handler self.message_handler = MessageHandler(self) # handlers self.handler_status = status.Status(self)
async def on_message(message): if message.content.startswith("j!galug"): if message.channel.permissions_for(message.author).manage_messages: await bot.send_file(message.channel, fp="galug.png") if message.content.startswith("j!haha"): if message.channel.permissions_for(message.author).manage_messages: await bot.send_file(message.channel, fp="haha.png") if message.channel.id == "326711493674532864": await bot.add_reaction(message, '👍') await bot.add_reaction(message, '👎') await bot.add_reaction( message, discord.Emoji(id=405404517358764043, server=discord.Server(id=160246330701250560))) if message.content.lower() == "jane fly sun": await bot.send_message( message.channel, "No you can not fly into the sun, you will most certainly burn up and die" ) if message.content.lower() == "jane dynmap link": await bot.send_message(message.channel, "http://starquest.spacebeaverstudios.com:8123") if message.content.lower() == "thanks jane": await bot.send_message(message.channel, "You're welcome :)") if message.content.lower() in [ "jane resourcepack link", "jane respack link", "jane texturepack link" ]: await bot.send_message( message.channel, "https://www.dropbox.com/s/diobsw0vcdiuj3o/SQLite.zip?dl=0") await bot.process_commands(message)
def onEnable(self): if not discord or not PY3: self.log.warning( "Discord Relay plugin requires Python 3 and the discord import." ) return False self.client = discord.Client() self.server = discord.Server(id="serverID") self.sendChannel = discord.Channel(name="channelName", server=self.server, id="channelID") self.api.registerEvent("player.message", self.player_message) self.api.registerEvent("player.login", self.login) self.discord_storage = self.api.getStorage("discord") self.player_data = self.discord_storage.Data self.api.registerCommand("disctoggle", self._toggle, None) self.api.registerHelp( "DiscordRelay", "sends and receives messages from Discord", [("/disctoggle", "toggles whether you want to communicate with the Discord server", None)]) @self.client.event async def on_message(message): for p in self.api.minecraft.getPlayers(): if self.player_data[p.uuid]: p.message(message) self.client.start("token")
async def start_player(): global started global player global main_queue global auto global voice global current global total_time global state before_args = "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5" server = discord.Server(id=configs.SERVER_ID) voice = bot.voice_client_in(server) player = await voice.create_ytdl_player(auto[0], ytdl_options=opts, before_options=before_args) print(player) gname_main = await get_vid_info(auto[0]) gname = "►" + gname_main['title'] await bot.change_presence(game=discord.Game(name=gname)) current = auto[0] info = await get_vid_info(current) total_time += info['duration'] auto.pop(0) state = "PLAYING" player.start() started = True
async def speak(script): server = discord.Server(id=configs.SERVER_ID) voice = bot.voice_client_in(server) decrequest.talk(script) player = voice.create_ffmpeg_player('dectalk.wav') print("HELLO!") player.start()
async def final(self, ctx, *, gamemode): """Notify a game is starting""" toscd = discord.Server(id='288455332173316106') optinrole = discord.Role(id='379748801197637644', server='288455332173316106') if gamemode is None: gamemode = "Not defined" gamemode = str(gamemode) auth = str(ctx.message.author.id) await self.bot.edit_role(toscd, optinrole, name="Game Notifications", colour=discord.Colour(0x880999), mentionable=True) await self.bot.say( """<@&379748801197637644> **||** This is the final call for a game of **""" + gamemode + """** is starting. The game will start shortly. Use `/joingame [Town of Salem IGN]` or `/jg [ToS IGN]` to join. You will shortly after get a party invite.""" ) await self.bot.edit_role(toscd, optinrole, name="Game Notifications", colour=discord.Colour(0x880999), mentionable=False)
async def host(self, ctx, *, gamemode): """Notify a game is starting""" channel = ctx.message.channel channelid = str(channel.id) authorid = str(ctx.message.author.id) toscd = discord.Server(id='288455332173316106') optinrole = discord.Role(id='358655924342095874', server='288455332173316106') if gamemode is None: gamemode = "Not defined" gamemode = str(gamemode) auth = str(ctx.message.author.id) await self.bot.edit_role(toscd, optinrole, name="Coven Notifications", colour=discord.Colour(0x550a94), mentionable=True) await self.bot.say("""<@&358655924342095874> **||** A new game of **""" + gamemode + """** is starting. Use `/joingame [Town of Salem IGN]` or `/jg [ToS IGN]` to join. You will shortly after get a party invite.""") await self.bot.edit_role(toscd, optinrole, name="Coven Notifications", colour=discord.Colour(0x550a94), mentionable=False) await self.bot.send_message(self.bot.get_channel('407003125128495104'), "Names for the game of **" + str(gamemode) + "** are being posted below.")
def submission_puller(self, entry): yield from self.wait_until_ready() channel = discord.Channel( server=discord.Server(id='260325692040937472'), id=entry[0]) self.pool[entry[0]] = entry[1][:] b = True while not self.is_closed: if self.localtime.localize( datetime.today()).minute in [0, 15, 30, 45]: if b: b = False if len(self.pool[entry[0]]) == 0: self.pool[entry[0]] = entry[1][:] pop_index = random.randint(0, len(self.pool[entry[0]]) - 1) selection = self.pool[entry[0]].pop(pop_index) for submission in self.reddit.subreddit(selection).hot( limit=10): if not submission.is_self: yield from self.send_message( channel, submission.url) submission.hide() break else: if not b: b = True self.todayTZ = self.localtime.localize(datetime.today()) yield from asyncio.sleep(30)
async def unmute(ctx, member: discord.Member): try: if ctx.message.channel.permissions_for( ctx.message.author).manage_messages: await bot.remove_roles( member, discord.Role(server=discord.Server(id=server), id=role)) await bot.say("{0.name} has been ungulagged".format(member)) except Exception as e: await bot.say(e)
async def create_channels(ctx): if "553129176043880458" or "546331545259212800" in [ role.id for role in ctx.message.author.roles ]: server = discord.Server(id='541468834473836566') await Breakouts.create_channel(server, 'Change Name', type=discord.ChannelType.voice) await Breakouts.say("**CHANNEL CREATED :new_moon_with_face: **") else: await Breakouts.say("*Administrators only command*")
async def mute(ctx, member: discord.Member): try: if ctx.message.channel.permissions_for( ctx.message.author).manage_messages: await bot.add_roles( member, discord.Role(server=discord.Server(id=server), id=role)) await bot.send_file( ctx.message.channel, fp="gulag.png", content='{0.name} has been gulagged'.format(member)) except Exception as e: await bot.say(e)
async def gamemodes(self, ctx): """Vote for today's gamemodes""" toscd = discord.Server(id='288455332173316106') optinrole = discord.Role(id='379748801197637644', server='288455332173316106') classic = discord.Emoji(id='386748316894887938', server=toscd) rp = discord.Emoji(id='386742079252070401', server=toscd) custom = discord.Emoji(id='386742078975115265', server=toscd) eve = discord.Emoji(id='386742078912069633', server=toscd) rm = discord.Emoji(id='386748316886499328', server=toscd) aa = discord.Emoji(id='386742078421467159', server=toscd) rain = discord.Emoji(id='386742078845222937', server=toscd) vigil = discord.Emoji(id='386742078471667714', server=toscd) await self.bot.edit_role(toscd, optinrole, name="Game Notifications", colour=discord.Colour(0x880999), mentionable=True) msg = await self.bot.say( """<a:animpartyblob1:401122373236948993> <a:animpartyblob2:401122373367234570> <a:animpartyblob3:401122373396463616> <a:animpartyblob4:401122373262376971> <a:animpartyblob5:401122373425823744> <a:animpartyblob6:401122373614567434> <a:animpartyblob7:401122373698322432> <a:animpartyblob8:401122373270503427> <a:animpartyblob9:401122373434343431> <@&379748801197637644> **||** We're voting for today's gamemodes! React to a gamemode to react. You may choose more than 1. **You may choose from these options:** <:NormalClassic:386748316894887938> - Classic. <:NormalRankedPractice:386742079252070401> - Ranked Practice. <:CustomCustom:386742078975115265> - Custom. <:CustomEvilsvEvils:386742078912069633> - Evils v Evils. <:CustomRapidMode:386748316886499328> - Rapid Mode. <:ChaosAllAny:386742078421467159> - All Any. <:ChaosRainbow:386742078845222937>- Rainbow. <:ChaosVigilantics:386742078471667714> - Vigilantics.""") await self.bot.edit_role(toscd, optinrole, name="Game Notifications", colour=discord.Colour(0x880999), mentionable=False) await self.bot.add_reaction(msg, classic) await self.bot.add_reaction(msg, rp) await self.bot.add_reaction(msg, custom) await self.bot.add_reaction(msg, eve) await self.bot.add_reaction(msg, rm) await self.bot.add_reaction(msg, aa) await self.bot.add_reaction(msg, rain) await self.bot.add_reaction(msg, vigil)
async def science(ctx): if ctx.message.server.id == "160246330701250560": member = ctx.message.author if discord.Role(server=discord.Server(id=server), id="439700931932585987") not in member.roles: await bot.add_roles( member, discord.Role(server=discord.Server(id=server), id=439700931932585987)) msg = await bot.send_message( ctx.message.channel, "You have recieved the Scientist role") await asyncio.sleep(10) await bot.delete_message(ctx.message) await bot.delete_message(msg) else: await bot.remove_roles( member, discord.Role(server=discord.Server(id=server), id="439700931932585987")) msg = await bot.say("You no longer have the Scientist role") await asyncio.sleep(10) await bot.delete_message(ctx.message) await bot.delete_message(msg)
async def main_task(): global client startupdelta = time.time() - jose.start_time jcommon.logger.info("--- STARTUP TOOK %.2f SECONDS ---", startupdelta) if jose.off_mode: msgid = random.getrandbits(80) userid = str(random.getrandbits(80)) jcommon.ADMIN_IDS.append(userid) user_dis = str(random.randint(1111, 9999)) channelid = str(random.getrandbits(80)) serverid = str(random.getrandbits(80)) # create discord objects _server = discord.Server(name='Offline José Mode', id=serverid) userdict = {'name': 'Offline Admin', 'id': userid, \ 'discriminator': user_dis, 'avatar': None, 'bot': False, \ 'server': _server} _channel = discord.Channel(name='talking', server=_server, \ id=channelid, is_private=False, is_defualt=True) jcommon.logger.info("You are %s#%s", userdict['name'], \ userdict['discriminator']) # am I really doing this? overwrite_discord_client() while True: msg = input("José> ") message = discord.Message(content=msg, channel=_channel, \ author=userdict, id=str(msgid), reactions=[]) msgid += 1 await on_message(message) else: try: jcommon.logger.info("[start] discord client") await client.start(jconfig.discord_token) jcommon.logger.info("[exit] discord client") except discord.GatewayNotFound: jcommon.logger.error("Received GatewayNotFound from discord.") except Exception as err: jcommon.logger.error("Received %r from client.start", err, exc_info=True)
async def Rev_action(ctx, role: discord.Role): server = discord.Server(id='541468834473836566') # gt_bans = await Breakouts.replace_roles(member , "Member" , "Moderator" , "Founder") #await Breakouts.say(gt_bans + "**ROLES REPLACED FOR SECURITY PURPOSES**") if "553129176043880458" or "546331545259212800" in [ role.id for role in ctx.message.author.roles ]: overwrite = discord.PermissionOverwrite() overwrite.read_messages = True overwrite.ban_members = False await Breakouts.edit_channel_permissions(ctx.message.channel, role, overwrite) await Breakouts.say( f"**CHANNEL OVERRIDED, SENDING AND READING MESSAGES ENABLED** HAULTING TILL FURTHER NOTICE " ) else: await Breakouts.say( "*First warning, do not attempt to use admin commands*")
async def command_unban(self, message): cont = False for role in message.author.roles: if role.name.lower() in config.warn_command_allowed_roles: cont = True if not cont: return if len(message.content.split()) < 2: await self.client.send_message(message.channel, 'Please include the user\'s id!') return con = self._delete_first_word(message.content) user_id = str((con).split()[0]) server_id = str(message.server.id) server = discord.Server(id=server_id) user = await self.client.get_user_info(user_id) if len(message.content.split()) < 3: await self.client.send_message(message.channel, 'Please include a reason!') return reason = self._delete_first_word(con) response = 'by {}'.format(message.author) db.add_unban(user_id, response) embdstaff = discord.Embed( title="Unbanned", type='rich', description= "Done! User with id: {} has been unbanned from the server by {}". format(user_id, message.author), colour=discord.Colour.green()) embdstaff.add_field(name='Reason', value='```{}```'.format(reason)) embdstaff.add_field(name='User ID', value="```{}```".format(user_id)) await self.client.send_message(discord.Object(id=config.logs_id), embed=embdstaff) await self.client.unban(server, user)
def daily_puzzle(self): yield from self.wait_until_ready() channel = discord.Channel( server=discord.Server(id='260325692040937472'), id='314032599838359553') parser = html2text.HTML2Text() parser.ignore_links = True done = False while not self.is_closed: if self.localtime.localize(datetime.today()).hour == 10: if self.localtime.localize(datetime.today()).minute == 0: feed = feedparser.parse('https://thinkwitty.com/feed') index = 0 while not done and index < 5: if feed.entries[index]['tags'][1][ 'term'] == 'Puzzle of the day': done = True text = parser.handle( feed.entries[4]['content'][0]['value']) index = text.find('https://') end = index for x, val in enumerate(text[index:]): if val == '?': end += x break image_link = text[index:end].replace('\n', '') yield from self.send_message(channel, image_link) else: index += 1 else: if not done: done = False self.todayTZ = self.localtime.localize(datetime.today()) yield from asyncio.sleep(30)
def on_member_join(self, member): non_default = self.json_data['Commands']['on_join']['User-Defined'] default = self.json_data['Commands']['on_join']['Default-Message'] server = discord.Server(id=member.server.id, name=member.server) server.name = member.server.name server.id = member.server.id container = discord.Message(author={ 'id': member.id, 'server': member.server.id }, reactions=[], content='') container.server = server container.author.name = member.name if non_default is not None: yield from self.send_message( discord.Channel(server=server, id='346821860589305858'), self.format_string(non_default, container)) else: yield from self.send_message( discord.Channel(server=server, id='346821860589305858'), self.format_string(default, container))
e = open("enrolledList.txt") enrolledList = [[]] try: for x in e: x = x.rstrip('\n').upper().split(" ") enrolledList.append(x) finally: if f is not None: f.close() enrolledList.__delitem__(0) TOKEN = '' client = commands.Bot(command_prefix="!") server = discord.Server(id='482530936412700703') # Code to cycle server icon # async def my_background_task(): # await client.wait_until_ready() # i = 0 # iconDir = '' # CNTSserver = client.get_server('490213374974754837') # while not client.is_closed: # if i == 0: # iconDir = 'SLC_Icon_1.png' # i += 1 # elif i == 1: # iconDir = 'SLC_Icon_2.png' # i += 1 # else:
import discord import asyncio from discord.ext.commands import Bot import math import random import sys from server import * startup_extensions = ["extensions.charSheets", "extensions.map", "extensions.combat"] currentState = {'mapType' : 0} myBot = Bot(command_prefix="!") server = discord.Server(id = serverID) @myBot.command() async def roll(*args): roll = math.floor(random.random() * 10) + 1 return await myBot.say("Rolling 1d10{0}. Result: {1}{0}={2}".format(args[0], roll, roll + int(args[0]))) @myBot.command() async def quit(*args): await myBot.say("Shutting down") sys.exit() if __name__ == "__main__": for extension in startup_extensions: try: myBot.load_extension(extension)
wClient = wolframalpha.Client(wolframid) bot.remove_command("help") try: with open("token.txt") as f: for line in f: DISCORD_API_ID = line token = line ip = line except FileNotFoundError as e: DISCORD_API_ID = getpass.getpass('Discord API: ') token = getpass.getpass('Token: ') ip = "172.93.48.238:25565" server = discord.Server(id=DISCORD_API_ID) roles = server.roles @bot.event async def on_ready(): print('Logged in as') print(bot.user.name) print('------') @bot.command(pass_context = True) async def iam(ctx, course : str): course = course.lower() found = 0 for i in range(0, len(ctx.message.server.roles)): if course == ctx.message.server.roles[i].name: found = i
# https://github.com/Rapptz/discord.py/blob/async/examples/reply.py import discord import time import random import urllib.request, json import asyncio TOKEN = 'NDMwNjE0MTE3NzU4NTMzNjMy.DaSwSQ.rPimEBXEiL_kNp3ZpTiLKdqnuWA' client = discord.Client() server = discord.Server(id='370127079863484416') def Boolczech(x): if x.lower() in ['true']: return True return False @client.event async def on_message(message): # we do not want the bot to reply to itself if message.author == client.user: return if message.content.startswith('\\hello'): array = message.content.split(' ') var = False if len(array) > 1: var = Boolczech(array[1].lower()) while 1: if time.gmtime().tm_min == 0 or var == True: west = list()
import discord import asyncio import random from discord.ext import commands client = commands.Bot(command_prefix=".") server = discord.Server(id="478247509328920576") ############################## Player = {} Alive = [] Dead = [] ############################## Area = { "giảng-đường": [], "hành-lang": [], "lớp-học": [], "phòng-thực-hành": [], "phòng-thể-chất": [], "thư-viện": [], "căn-tin": [] } ############################## Arena = [ "giảng-đường", "hành-lang", "lớp-học", "phòng-thực-hành", "phòng-thể-chất", "thư-viện", "căn-tin" ] ############################## ItemArena = { "hành-lang": [["Mảnh Kính", 15], ["Ống Sắt Rỗng", 10], ["Tấm Sắt", 8], ["Đá", 15]], "lớp-học": [["Giấy Dày", 15], ["Bút Chì", 10], ["Gỗ", 8],
import discord import ast import asyncio import random import os import re import time import random import sys import ast import operator #---------------------------------------------Globals-------------------------------------------------# client = discord.Client() vServer = discord.Server(id='329432484280270850') vBotId = 'Curse Chat Bot#8700' vModRoles = [ 'Lords of Chochi', #0 'Knights of Chochi', #1 'The King in the Raj' #2 list of mod roles in the server. (who can control the bot) ] vChatEmojis = [ ':ok_hand:', #0 ':joy:', #1 ':thumbsup:', #2 list of emoji codes to use in the chat ':punch:', #3 ':headphones:', #4 ':fire:', #5 ':hammer:', #6
from event_bus import EventBus from github import Github from message_handler import MessageHandler from secret import SecRet # read configs with open('configs.json', 'r') as f: configs = json.load(f) # event bus and loop main_loop = asyncio.get_event_loop() bus = EventBus() # discord client = discord.Client() secret_server = discord.Server(id='326095959173890059') secret_channel = discord.Channel(id='404630967257530372', server=secret_server) welcome_channel = discord.Channel(id='404795628019777557', server=secret_server) # github g = Github(configs['github_username'], configs['github_password']) repo = g.get_repo('iGio90/secRet_dBot') # message handler message_handler = MessageHandler(bus, client, secret_server, secret_channel, repo) # secret thread for additional periodic stuffs secret = SecRet(bus, repo) secret.setName('secRet')
self.falas.append(frase) frase = '' contador = 0 self.falas_copia = self.falas[:] def __str__(self): if len(self.falas_copia) == 0: self.falas_copia = self.falas[:] mensagem = self.falas_copia.pop( random.randint(0, len(self.falas_copia) - 1)) return mensagem client = discord.Client() server = discord.Server(id='447168484124655647') haxboys = [] with open('haxboys.txt', 'r') as arquivo: for linha in arquivo: for autista in linha.split(sep=';'): haxboys.append( Haxboys(filename='hb/' + autista + '.txt', avatar='hb/' + autista + '.png')) @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) boteco = client.get_channel('524737257945694243') bot = list(client.servers).pop().me #cria o objeto membro referente ao bot tempo_inicial = time.time() - 100000
class Servers: FGL = discord.Server(id='380104197267521537')