Guest User

Untitled

a guest
Feb 14th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.90 KB | None | 0 0
  1.                     Inside of slash command:
  2.  
  3.                     u1 = disnake.ui.Button(custom_id='u1', label='U1', style=disnake.ButtonStyle.blurple, row=0)
  4.                     u2 = disnake.ui.Button(custom_id='u2', label='U2', style=disnake.ButtonStyle.blurple, row=0)
  5.                     u3 = disnake.ui.Button(custom_id='u3', label='U3', style=disnake.ButtonStyle.blurple, row=0)
  6.                     u4 = disnake.ui.Button(custom_id='u4', label='U4', style=disnake.ButtonStyle.blurple, row=0)
  7.                     u5 = disnake.ui.Button(custom_id='u5', label='U5', style=disnake.ButtonStyle.blurple, row=1)
  8.                     u6 = disnake.ui.Button(custom_id='u6', label='U6', style=disnake.ButtonStyle.blurple, row=1)
  9.                     u7 = disnake.ui.Button(custom_id='u7', label='U7', style=disnake.ButtonStyle.blurple, row=1)
  10.                     u8 = disnake.ui.Button(custom_id='u8', label='U8', style=disnake.ButtonStyle.blurple, row=1)
  11.                    
  12.  
  13.                     u1.callback = u1callback(codeid)
  14.                     u2.callback = u2callback(codeid)
  15.                     u3.callback = u3callback(codeid)
  16.                     u4.callback = u4callback(codeid)
  17.                     u5.callback = u5callback(codeid)
  18.                     u6.callback = u6callback(codeid)
  19.                     u7.callback = u7callback(codeid)
  20.                     u8.callback = u8callback(codeid)
  21.                    
  22.                     view = disnake.ui.View(timeout=None)
  23.                    
  24.                     view.add_item(u1)
  25.                     view.add_item(u2)
  26.                     view.add_item(u3)
  27.                     view.add_item(u4)
  28.                     view.add_item(u5)
  29.                     view.add_item(u6)
  30.                     view.add_item(u7)
  31.                     view.add_item(u8)
  32.  
  33.  
  34. outside of slash command:
  35.  
  36. async def u1callback(codeid):
  37.     await upscale(disnake.ApplicationCommandInteraction, number=1, code=codeid)
  38.    
  39. async def u2callback(codeid):
  40.     await upscale(disnake.ApplicationCommandInteraction, number=2, code=codeid)
  41.  
  42. async def u3callback(codeid):
  43.     await upscale(disnake.ApplicationCommandInteraction, number=3, code=codeid)
  44.  
  45. async def u4callback(codeid):
  46.     await upscale(disnake.ApplicationCommandInteraction, number=4, code=codeid)
  47.  
  48. async def u5callback(codeid):
  49.     await upscale(disnake.ApplicationCommandInteraction, number=5, code=codeid)
  50.  
  51. async def u6callback(codeid):
  52.     await upscale(disnake.ApplicationCommandInteraction, number=6, code=codeid)
  53.  
  54. async def u7callback(codeid):
  55.     await upscale(disnake.ApplicationCommandInteraction, number=7, code=codeid)
  56.  
  57. async def u8callback(codeid):
  58.     await upscale(disnake.ApplicationCommandInteraction, number=8, code=codeid)
  59.  
  60. other slash command
  61.  
  62. @bot.slash_command(description='Generates images using Stable Horde!')
  63. async def generate(
  64.     inter: disnake.ApplicationCommandInteraction,
  65.     prompt: str = commands.Param(description='What the AI-generated image should be of.'),
  66.     neg_prompt: str = commands.Param(default = '2D, grid, text', description='What the AI image model should avoid. Default: \'2D, grid, text\''),
  67.     upscalers: str = commands.Param(choices=settings.processor_list, default='GFPGAN', description='Which Post-Processing to use for the images. Default: GFPGAN'),
  68.     model: str = commands.Param(default=settings.default_model,choices=settings.model_list, description='Which model to generate the image with. Default: ' + str(settings.default_model)),
  69.     cfg_scale: Optional[float] = commands.Param(default=8, le=30, ge=-40, description='How much the image should look like your prompt. Default: 8'),
  70.     #imageurl: str = commands.Param(name = 'init_image', default = None, description='Initial image for img2img.'),
  71.     width: int = commands.Param(default = settings.default_width, le=1024, ge=64, description='Width of the final image. Default: ' + str(settings.default_width)),
  72.     height: int = commands.Param(default = settings.default_height, le=1024, ge=64, description='Height of the final image. Default: ' + str(settings.default_height)),    
  73.     sampler: str = commands.Param(default = settings.default_sampler, description = 'ADVANCED: Which stable diffusion sampler to use. Default: ' + settings.default_sampler, choices=settings.sampler_list),
  74.     steps: int = commands.Param(default=settings.default_steps, le=50, ge=1, description='Greater: Higher Image Quality but takes longer. Default: ' + str(settings.default_steps)),
  75.     seed: int = commands.Param(default=-1, description='Seed for the image.')
  76. ):
  77.  
  78.  
  79. error:
  80.  
  81. ```sh
  82. Ignoring exception in view <View timeout=None children=8> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='U1' emoji=None row=0>:
  83. Traceback (most recent call last):
  84.   File "/Users/oriontomasi/opt/anaconda3/lib/python3.9/site-packages/disnake/ui/view.py", line 385, in _scheduled_task
  85.     await item.callback(interaction)
  86. TypeError: 'coroutine' object is not callable
  87. ```
Advertisement
Add Comment
Please, Sign In to add comment