Nextcord is there a way to make a cog but make it disabled by default - nextcord

Basically I'm trying to make a cog where I added some pranks but I want to make it disabled(unloaded) by default is there any way to do that?

Yes. You can change the cog's name to something like:
_cogname.py
And when you load your cogs, do the following:
for filename in os.listdir('./cogs'):
if filename.endswith('.py') and not filename.startswith('_'):
bot.load_extension(f'cogs.{filename[:-3]}')
Make sure you do:
import os
at the start of your code

Related

why scrapy won't load any of my pipelines?

ok, so Im using Scrapy for some basic web scraping and its working fine on scraping part! when get some output using feed export something like -o output.csv wont do anything, it will make an empty file but nothing else.
after a period of confusion I couldn't make it work so i've decided to use a pipeline to write some custom method of exporting. but now the problem is even though the application is working fine... its just not load the pipelines. not any single one of them is not running and there is no error.
this is my settings.py where I put the option to load them:
ITEM_PIPELINES = {
'fbcrawl.pipelines.CsvExporterPipeline': 300
}
and this is my CsvExporterPipeline class inside pipelines.py:
class CsvExporterPipeline(object):
def process_item(self, item, spider):
print('\n' * 2)
print(item)
print('\n' * 2)
return item
and its not gonna run neither of these 3 prints wont run at all.
I want to know how can I have my pipelines loaded and working?
UPDATE: i forgot to mention that im trying to run this code... so the spider is mentioned here:
https://github.com/rugantio/fbcrawl
Are you sure BOT_NAME in settings.py is set at fbcrawl ?
And what is the code of your spider ?

How to format default help command

Can someone please tell me how to format the Default help command in discord.py
I already know how to change the description however, I want to be able to change the width and sort them alphabetically.
Thanks for any help
:)
You can override certain functions in the default help command. Below is an official example on how to set this up initially:
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
The example above overrides the implementation of get_command_signature.
As you can see, you're supposed to create a new HelpCommand class and change the functions. Stuff that you don't want to change can just be left untouched, you don't have to copy-paste the existing code in there.
To see what a HelpCommand and MinimalHelpCommand can do (to override the methods), I suggest scrolling through the relevant API Documentation.
This way, in case there's something that you don't like about the default help, you can just change it's behaviour and fix it yourself. In your case, you're gonna want to sort the list of commands before adding them to the codeblock.
I recommend flicking through the default implementation's functions to see what you have to change about it. In your case, send_bot_help, send_cog_help, send_command_help, and send_group_help will need the lists sorted.

ICDevice not ready

I'm trying to write a simple Cocoa App to scan some documents from my USB-scanner. I use it the same way as this example of apple: https://developer.apple.com/library/mac/samplecode/ScannerBrowser/Listings/AppController_m.html
The 'deviceBrowser:didAddDevice...' method is called. There I set the scanners delegate to self (like in the example), but the methods 'deviceDidBecomeReady' or 'scannerDeviceDidBecomeAvailable' are never called.
Is there anything I have forgotten?
Here is the code:
http://pastebin.com/NHZ0j5ze
Oh... reading the .h-files of the frameworks should still be the first option. The order was wrong and I forgot didOpenSessionWithError.
Here is the working code:
http://pastebin.com/NDEY5S13

Conditional first run handler

I wonder if someone can help me with a simple script. I am not a good Titanium programmer yet, but I would like to be some day.
I need help with a script to check whether a certain settings file exists in the applicationDataDirectory.
I need a way to trigger this automatically in app.js:
If file with the with the name: "passWord.txt” does not(!) exist in applicationDataDirectory
then open window:
var w = Ti.UI.createWindow
I can´t find a event to check for this file and then open this window automatically. This will work as a “first run” event when the app is loaded the first time.
Try this
var file =Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,"passWord.txt”);
if ( file.exists() ) {
// do your work here.
}
For complete details Titanium.Filesystem.File.

Programatically moving through a ListView in Qt (Ruby)

I'm making a small file-browser for my own use, in Ruby, and using Qt for the view. The idea is that it'll end up on my TV, where I can use the remote to move up and down and launch files.
Everything works fine, until I'm going to move the selection using the remote. I managed to set up a D-Bus service, so I'll just call the methods using LIRC.
The code I'm using for setting up the view looks like this:
#dm = Qt::DirModel.new
#sm = Qt::ItemSelectionModel.new(#dm)
#lv = Qt::ListView.new
#lv.model = #dm
#lv.selectionModel = #sm
cwd = #dm.index(#dir)
#lv.rootIndex = cwd
And then I'm unsure how to change the selection. Think I must have tried about every setIndex, setSelection and every method sounding similar, on the DirModel, ItemSelectionModel and ListView, without any luck. I've been googling and reading through the API without finding anything.
Ideally, I would have something like "moveSelectionDown" and "moveSelectionUp" that takes care of it, and making sure it wraps around correctly. But I can't seem to find anything.
Managed to fix it through the ItemSelectionModel every view apparently has.
moving up:
curIndex = #lv.currentIndex
#lv.selectionModel.setCurrentIndex(curIndex.sibling(curIndex.row-1, 0), Qt::ItemSelectionModel::ClearAndSelect)
or adding one to move down
I think you're forgetting that you have to create the ModelIndex through your model:
#dm.index(3, 0, None)
I'd try this method (Though I'm not really sure, this deselects the other cells.)
#lv.setCurrentIndex(#dm.index(3, 0, None))
I haven't used Ruby for ages, so I'm not exactly sure there's None.

Resources