Advertisement
Guest User

はい、これで行けるはずだぞ(再起動とか)

a guest
Feb 14th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. import os
  4.  
  5. client = commands.Bot(command_prefix='b!')
  6. client.remove_command('help')
  7.  
  8.  
  9. @client.event
  10. async def on_command_error(ctx, error):
  11. if isinstance(error, commands.CommandNotFound):
  12. await ctx.channel.send(f"コマンドが正しくありません。\nb!helpを参照してください。\n実行コマンド:{ctx.content}")
  13.  
  14.  
  15.  
  16.  
  17. @client.event
  18. async def on_ready():
  19. ch = await client.fetch_channel("672431630656208910")
  20. await ch.send("ブロッコリーが起動しました!\nブロッコリーは起動しないか、ブロッコリーシステムが起動したのか!")
  21.  
  22.  
  23.  
  24.  
  25. @client.event
  26. async def on_message(message):
  27. if message.author.bot:
  28. # もし、送信者がbotなら無視する
  29. return
  30. GLOBAL_CH_NAME = "broliy-global" # グローバルチャットのチャンネル名
  31. if message.channel.name == GLOBAL_CH_NAME:
  32. # broliy-globalの名前をもつチャンネルに投稿されたので、メッセージを転送する
  33. await message.delete() # 元のメッセージは削除しておく
  34. channels = client.get_all_channels()
  35. global_channels = [ch for ch in channels if ch.name == GLOBAL_CH_NAME]
  36. # channelsはbotの取得できるチャンネルのイテレーター
  37. # global_channelsは broliy-global の名前を持つチャンネルのリスト
  38. embed = discord.Embed(title="Global",description=message.content, color=0x00bfff)
  39. embed.set_author(name=message.author.display_name,icon_url=message.author.avatar_url_as(format="png"))
  40. embed.set_footer(text=f"{message.guild.name} / {message.channel.name}",icon_url=message.guild.icon_url_as(format="png"))
  41. # Embedインスタンスを生成、投稿者、投稿場所などの設定
  42. for channel in global_channels:
  43. # メッセージを埋め込み形式で転送
  44. await channel.send(embed=embed)
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. @client.command()
  53. async def help(ctx, serverid):
  54. await ctx.send('>>> ヘルプを表示しています。\nb!help 今表示してるやつだよ\nb!youtube 開発者のYouTubeチャンネル表示\nb!intro_bot このBOTの紹介ビデオを表示するよ!\nb!server_list 公認サーバーのリストを表示')
  55.  
  56.  
  57.  
  58. @client.command()
  59. async def youtube(ctx, serverid):
  60. await ctx.send('>>> 開発者ぶろりーのYouTubeドス!\nhttps://www.youtube.com/channel/UCbp2wAJ1JBYGwXeAQLICAUw?view_as=subscriber%60%60%60')
  61.  
  62.  
  63.  
  64. @client.command()
  65. async def intro_bot(ctx, serverid):
  66. await ctx.send('>>> BROLIY SYSTEMの紹介動画です。\n-まだ無い..許してヒヤシンス-')
  67.  
  68.  
  69.  
  70. @client.command()
  71. async def server_list(ctx, serverid):
  72. await ctx.send('>>> 公認サーバーのリストです。\n【公式】マイクラ採掘鯖 -石鯖- \nhttps://discord.gg/RGwTZzf/nのぶりんマイクラ逃走中サーバー/nhttps://discord.gg/y3YYAng/n【公式】MCBEbans -統合版荒らしデータベース-\nhttps://discord.gg/92eH2U7')
  73.  
  74.  
  75.  
  76. @client.command()
  77. async def restart(ctx, serverid):
  78. await ctx.send('bot自体を再スタートします。')
  79. os.system("shutdown -r -t 0")
  80.  
  81.  
  82.  
  83. @client.command()
  84. async def runcmd(ctx, *, cmd):
  85. k = os.system(cmd)
  86. await ctx.send(k)
  87.  
  88.  
  89.  
  90.  
  91. @client.command()
  92. async def leaveserver(ctx, serverid):
  93. guild = fetch_guild(serverid)
  94. await guild.leave()
  95. await ctx.send(f"{guild.name}から退出しました。")
  96.  
  97.  
  98.  
  99.  
  100.  
  101. client.run('aaaaa')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement