I am trying to get the guild's icon url. How do i use icon_url to grab the link?
#client.command()
async def servericon(ctx):
await ctx.send(discord.Guild.icon_url)
I expected to get guild's icon url, but got "property object at 0x000002683BB548B8" this instead.
You're using the property of the class, you need to use the property of the instance that represents the specific guild you're interested in. In you case, this will probably be ctx.guild.icon_url
Related
Problem: The optional context.auth.uid is expected to be part of the parameters of a firebase trigger, but is not being provided.
I am writing a document onCreate trigger on Firebase Cloud Functions. This trigger will write a sub-collection document using some of the data from the triggering document and the UID of the user who created it.
A standard trigger function will accept the following
export const onCreateUnit = functions.firestore.document('/units/{unitId}').onCreate((snap, context) => {
https://firebase.google.com/docs/reference/functions/providers_firestore.documentbuilder.html#oncreate
The context object should include an auth object which would contain the uid and token
context: {
...contextProperties,
auth: {
uid: XXXXXX-XXXX-XXXX,
token: YYYYYYYYYYY
}
}
Some things to keep in mind.
This is an optional property
This property should be filled if a user is creating this document
All documents in the firestore database have a rule implemented protecting against non-users creating documents.
The client side is a React-Typescript project
The client is signed in to Firebase and waits for the onAuthStateChanged function to pass a user before creating documents.
No errors are thrown
The trigger function is confirmed to be called when the triggering document is created.
The context.auth property is undefined
Why is there no auth property provided in the context? How can I fix it?
looks like you are not providing the data from the front-end to being with, check if your user is already logged in, happened to me couple of times.
so I'm trying to pass a dynamically generated URL to Image's source prop and, due to React Native limitations, I cannot simply pass a variable as the value of that prop because it won't update to load the image after the variable is set.
So I'm trying to follow the advice here to trigger a change to the source prop.
How can I set the value of a prop in useEffect?
Edit: this is what I'm trying, but still not successfully seeing the image
const [photoUrl, setPhotoUrl] = useState();
useEffect(() => {
async function getSetImg() {
let img = await getImage(job.afterPhoto.uri);
setPhotoUrl(img);
}
if (job) {
getSetImg;
}
}, [job]);
<Image
source={{ uri: photoUrl }}
style={styles.headerImage}
/>
The problem may not be from setting the values with useState/setState.
I have 2 suggestions you can try.
1. Check if Image style is set explicitly
Q) Does the image show when you hardcode the URL directly (without using setState)?
You can try using the Google logo image for uri: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png
NO (Image don't show): Try the below (style)
YES (Hardcoded image is shown ok): Try #2 (ATS)
From RN Docs on Image:
Note that for network and data images, you will need to manually specify the dimensions of your image!
If your styles.headerImage does not have height and width explicitly defined, the <Image/> component may not show. You can easily check if your <Image/> component is visible by setting the backgroundColor='red' while developing.
2. Check App Transport Security (ATS) settings
Q) Are you using iOS? Is the uri source in https or http?
If you are fetching image in http, check the ATS settings.
Also from RN Docs on ATS:
App Transport Security is a security feature introduced in iOS 9 that rejects all HTTP requests that are not sent over HTTPS.
Suggested fix from another SO question is to add NSAllowsArbitraryLoads in the info.plist.
I'm building a bot in discord and i would like to add a slash command feature that will allow the user to select a choice from many (like a drop down menu). However, you can't add more than 25 choices for a slash command option. So my alternative solution is to have a content matching preview like with giphy bot when the user type a string i will update the content accordingly.
However, i don't find any guide on how i can implement this behavior. is it about updating choices on interactionCreate event?
The way the bot is doing that is through something called Autocomplete. Basically, you can declare a command to have Autocomplete and then, in the interactionCreate event listener, you can check if the command is an Autocomplete interaction, then respond with something. You can set the command to be Autocomplete by using this in one of the options for the command:
.setAutocomplete(true)
Then, in your main file, where you have the interactionCreate event listener, you can just check when a command is an Autocomplete interaction by using interaction.isAutocomplete(). Then, you can respond to the interaction by using this:
const value = interaction.options.getFocused() // This gets the value which the user typed
const response = await interaction.respond({
name: '', // The name of the response
value: '' // The value of the response
})
You can learn more about Autocomplete here => Autocomplete | discord.js
However, I'm not sure if any bot can do that since this was hard coded to be like that by Discord and since bots can only respond with strings (I think).
I am new to react.js, and react-admin caught my eyes to use it. But I have a problem regarding to the endpoint it's using
http://localhost:3333/verifications/browse?filter=%7B%7D&range=%5B0%2C9%5D&sort=%5B%22id%22%2C%22ASC%22%5D
is it possible to remove the filter parameter? because I want to use my api which is
http://localhost:3333/verifications/browse?page=1&per_page=10&verification_level_id=1&verification_status_id=3
is it possible to override that? and use my api
Yes, it's totally possible: you have to tweak the dataProvider, which is a translation layer between react-admin's queries and your API.
Check out the documentation at: https://marmelab.com/react-admin/DataProviders.html
If you want to create filter like
?page=1&per_page=10&verification_level_id=1&verification_status_id=3
Here page=1&per_page=10 can be added by react admin list component, all you just need to pass props as pagination,per_page etc.
For the next part &verification_level_id=1&verification_status_id=3 you can create custom filter component and pass inside filter props and inside the filter component you can use useListContext hooks to get the filter.
List component will get this value inside filter as an object.
Now you can access those filter on data provider and manipulate it and use it.
Please read https://marmelab.com/react-admin/List.html
https://marmelab.com/react-admin/DataProviders.html
I'm using the pokeapi to return basic information about a pokemon from the pokeapi. Nothing is being rendered to the component. Not even the default value passed as a parameter(pikachu). When I inpspect the XHR response with the dev tools, a response object is being returned but it's not being displayed. Any suggestions?
I have a link to the sandbox code.
https://codesandbox.io/s/blissful-mountain-jvbwc?file=undefined
Ahh i see the issue
You need to change your searchPokemon method to use an arrow function because non-arrow functions are not this binding.
Another issue, you should update you catch statement to use console.error so you can see the error message in the console.